Skip to content

Update Deploy.yml

Update Deploy.yml #64

Workflow file for this run

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.GDSC_WEBSITE }}
REPO : "Google-DSC-Kookmin/Google-DSC-Kookmin.github.io"
PR_TITLE : "Deploy React Front Update"
PR_BODY : "Automatically generated PR to merge React Front updates"
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
mkdir build
echo "Github Action Test" > build/File.txt
- 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_${{ env.BRANCH_NAME }}
cp -r ../project-front/build/* .
git add .
git commit -m "Commit build result"
echo "${{ github.ref }}"
- name: Push to Second Repo
uses: ad-m/github-push-action@master
with:
branch: ${{ env.BRANCH_NAME }}
directory: second_repo
repository: ${{ env.REPO }}
- name: Open PR
id: open_pr
uses: rematocorp/open-pull-request-action@v1
with:
github-token: "${{ env.GITHUB_TOKEN }}"
from-branch: "${{ github.BRANCH_NAME }}"
to-branch: "main"
repository-owner: "${{github.repository_owner}}"
repository: "${{ env.REPO }}"