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 }}"}'