From 0c7bd985ab2c665e64cc5fef7fba105a5622967f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EC=A4=80=EC=88=98?= <99115509+hoheesu@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:20:04 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20deploy.yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a40122e..765274e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,7 +1,7 @@ name: Netlify Deploy on: - push: + pull_request: branches: - main # 프로덕션 배포 - develop # 테스트 배포 From 86bb2c1a4d82a236bd1b13a87b918222c5d8243e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EC=A4=80=EC=88=98?= <99115509+hoheesu@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:30:33 +0900 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20CICD=20=EB=B0=B0=ED=8F=AC=20url=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 765274e..d0c4c81 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,11 +23,9 @@ jobs: - name: Deploy to Netlify env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: '' # Netlify에서 제공된 Site ID + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} run: | npm install -g netlify-cli - if [ "${{ github.ref_name }}" = "main" ]; then - netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --prod --message "Production Deploy from main" - elif [ "${{ github.ref_name }}" = "develop" ]; then - netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --branch=develop --message "Develop Deploy" - fi + URL=$(netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --message "Develop branch deploy for testing" --json | jq -r .deploy_url) + echo "Deploy URL: $URL" + echo "TEST_DEPLOY_URL=$URL" >> $GITHUB_ENV From fdbed670b5d166cd5c6f05ac20ee1a8be1c129f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EC=A4=80=EC=88=98?= <99115509+hoheesu@users.noreply.github.com> Date: Fri, 6 Dec 2024 02:36:27 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20CICD=20=EB=B0=B0=ED=8F=AC=20url=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d0c4c81..f6ee6e8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,31 +1,46 @@ -name: Netlify Deploy +name: Netlify Deploy (Pull Request) on: pull_request: branches: - - main # 프로덕션 배포 - - develop # 테스트 배포 + - main # main 브랜치에 PR이 열리면 실행 + - develop # develop 브랜치에 PR이 열리면 실행 jobs: deploy: runs-on: ubuntu-latest steps: + # 코드 체크아웃 - name: Checkout code uses: actions/checkout@v3 + # 의존성 설치 - name: Install dependencies run: npm install + # 프로젝트 빌드 - name: Build project run: npm run build + # Netlify로 배포 - name: Deploy to Netlify env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} run: | npm install -g netlify-cli - URL=$(netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --message "Develop branch deploy for testing" --json | jq -r .deploy_url) - echo "Deploy URL: $URL" - echo "TEST_DEPLOY_URL=$URL" >> $GITHUB_ENV + DEPLOY_OUTPUT=$(netlify deploy --auth=$NETLIFY_AUTH_TOKEN --site=$NETLIFY_SITE_ID --message "Deploy for PR to develop" --json) + DEPLOY_URL=$(echo $DEPLOY_OUTPUT | jq -r .deploy_url) + echo "Deploy URL: $DEPLOY_URL" + echo "TEST_DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV + + # PR에 배포 URL을 주석으로 추가 + - name: Add deploy URL to PR comment + if: github.event_name == 'pull_request' + run: | + curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ + -d '{"body": "Test site deployed: '"$TEST_DEPLOY_URL"'"}' From b12cff74be717310b65032abcab896f2b3e64463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EC=A4=80=EC=88=98?= <99115509+hoheesu@users.noreply.github.com> Date: Fri, 6 Dec 2024 03:09:36 +0900 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20CICD=20=EB=B0=B0=ED=8F=AC=20url=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f6ee6e8..f8306e7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,7 +40,7 @@ jobs: if: github.event_name == 'pull_request' run: | curl -s -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Authorization: token ${{ secrets.MY_PAT }}" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ -d '{"body": "Test site deployed: '"$TEST_DEPLOY_URL"'"}'