From 233792a6a3fabd9b10d67d6c94432869113f1ebe Mon Sep 17 00:00:00 2001 From: San Kim Date: Sat, 21 Sep 2024 21:11:39 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=20?= =?UTF-8?q?=ED=8A=B8=EB=A6=AC=EA=B9=85=20=EB=B0=A9=EC=8B=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/cd-dev.yaml | 12 +++++++----- .github/workflows/ci.yaml | 10 ++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd-dev.yaml b/.github/workflows/cd-dev.yaml index f4f9347..0a32399 100644 --- a/.github/workflows/cd-dev.yaml +++ b/.github/workflows/cd-dev.yaml @@ -1,15 +1,14 @@ name: Continuous Deployment to Dev on: + repository_dispatch: + types: [trigger-cd] workflow_dispatch: inputs: version: description: 'Version to deploy (e.g., v1.2.3)' required: true type: string - push: - branches: - - main env: AWS_REGION: ap-northeast-2 @@ -39,10 +38,13 @@ jobs: - name: Determine version to deploy id: determine-version run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + if [ "${{ github.event_name }}" = "repository_dispatch" ]; then + echo "VERSION=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT + elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT else - echo "VERSION=latest" >> $GITHUB_OUTPUT + echo "Error: Unexpected event type" + exit 1 fi - name: Check if image exists in ECR diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index deec13a..78cb670 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -141,3 +141,13 @@ jobs: git config user.email github-actions@github.com git tag ${{ steps.generate-version.outputs.version }} git push origin ${{ steps.generate-version.outputs.version }} + env: + GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} + + - name: Trigger CD (DEV) Workflow + if: success() + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.REPO_ACCESS_TOKEN }} + event-type: trigger-cd + client-payload: '{"version": "${{ steps.generate-version.outputs.version }}"}'