Deploy to Github Page Repository(Google-DSC-Kookmin.github.io) #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Github Page Repository(Google-DSC-Kookmin.github.io) | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
push: | |
branches: | |
- Github_Action_Test | |
workflow_dispatch: # 수동 트리거 활성화 | |
permissions: | |
pull-requests: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
REPO : "Google-DSC-Kookmin/Google-DSC-Kookmin.github.io" | |
jobs: | |
Deploy_to_other_repo: | |
if: >- | |
github.event_name == 'workflow_dispatch' || | |
(github.ref == 'refs/heads/Github_Action_Test') || | |
((contains(github.event.pull_request.labels.*.name, 'no update') == false && github.event.pull_request.merged == true)) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
- name: Generate new branch name | |
run: | | |
TIME_STAMP=$(date +'%Y.%m.%d.%H.%M.%S') | |
echo "BRANCH_NAME=React-Front_$TIME_STAMP" >> $GITHUB_ENV | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name : Build React Page | |
run: | | |
cd project-front | |
npm install | |
CI=false npm run build | |
- name: Checkout repository 2 | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ env.GITHUB_TOKEN }} | |
repository: ${{ env.REPO }} | |
path: second_repo | |
- name: Create New Branch and Commit Build Result | |
run: | | |
cd second_repo | |
git pull | |
git config user.email "actions@github.com" | |
git config user.name "[Bot] GitHub Actions" | |
git checkout -b React-Front_$(date +'%Y.%m.%d.%H.%M.%S') | |
cp -r ../project-front/build/* . | |
git add . | |
git commit -m "Commit build result" | |
- name: Push to Second Repo | |
uses: ad-m/github-push-action@master | |
with: | |
branch: ${{ env.BRANCH_NAME }} | |
directory: second_repo | |
repository: ${{ env.REPO }} |