1. GitHub에서 일반 Public Repository 생성

 

2. Vercel에 방금 만든 Repository 연동

 

3. Organization Repository 루트 경로로 build.sh 파일 생성, [team-repo-name] 부분에 Organization Repository 이름 입력

#!/bin/sh
cd ../
mkdir output
cp -R ./[team-repo-name]/* ./output
cp -R ./output ./[team-repo-name]/

4. Organization Repository에 secret 변수 등록

- Settings -> Security -> Secrets and variables -> Actions -> Repository secrets
- GIT_EMAIL에는 GitHub 계정 이메일을, AUTO_ACTIONS에는 개인 계정에서 발급받은 token값을 넣는다.
- https://github.com/settings/tokens -> 개인 GitHub 설정에서 token을 만든다. reop 권한 체크. ghp_로 시작하는 token은 다시없으니 복사해서 보관한다.

 


5. GitHub Actions 활성화 + .github/workflows/github-actions.yml 생성

- Actions -> set up a workflow yourself -> 프로젝트 이름/.github/workflows/git-push.yml in main
- 웹에서 만들지 않고 VSCode 내에서 만들어보자. Oranization Repository의 프로젝트의 루트 디렉토리에서 .github/workflows 폴더를 생성, github-actions.yml 파일을 만듦.

 


- .github > workflows > github-actions.yml에 아래의 코드를 복붙.
- [destination-github-username]에는 개인 repo의 username을, [destination-repository-name]에는 repo 이름을 넣는다.

name: git push into another repo to deploy to vercel

on:
	push:
		branches: [main, develop]

jobs:
	build:
		runs-on: ubuntu-latest
		container: pandoc/latex
		steps:
  			- uses: actions/checkout@v2
  			- name: Install mustache (to update the date)
    		  run: apk add ruby && gem install mustache
  			- name: creates output
    		  run: sh ./build.sh
  			- name: Pushes to another repository
    		  id: push_directory
    		  uses: cpina/github-action-push-to-another-repository@main
    		  env:
      			API_TOKEN_GITHUB: ${{ secrets.AUTO_ACTIONS }}
    		  with:
      			source-directory: "output"
      			destination-github-username: "your-repo-github-username"
      			destination-repository-name: "your-repo-name"
      			user-email: ${{ secrets.GIT_EMAIL }}
      			commit-message: ${{ github.event.commits[0].message }}
      			target-branch: main
  			- name: Test get variable exported by push-to-another-repository
    		  run: echo $DESTINATION_CLONED_DIRECTORY

git add .
git commit -m ~
git push ~ 를 하면 GitHub의 Actions 탭에서 진행이 잘되는지 확인
배포 끝

728x90

'Git' 카테고리의 다른 글

만든 프로젝트를 git에 연동하기  (0) 2024.05.25