1414 type : choice
1515 options :
1616 - dev
17- - prod
17+ - prd
1818 push :
1919 branches :
2020 - " main"
2828 BUMP_RULE : ${{ (github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev') == 'dev' && '--stage' || '' }}
2929
3030 steps :
31- # Checkout source codes
3231 - name : Checkout source codes
3332 uses : actions/checkout@v4
3433 with :
@@ -56,11 +55,10 @@ jobs:
5655 id : info
5756 run : |
5857 LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1)
59- echo "::set-output name= TAG::$( python ./.github/scripts/get_new_version.py --current=$LATEST_TAG ${{ env.BUMP_RULE }})"
60- echo "::set-output name= date:: $(date +'%Y-%m-%d_%H:%M:%S')"
61- echo "::set-output name= repository_name:: $(echo ${{ github.repository }} | sed -e 's/${{ github.repository_owner }}\///')"
58+ echo "TAG=$(uv run python ./.github/scripts/get_new_version.py --current=$LATEST_TAG ${{ env.BUMP_RULE }})" >> "$GITHUB_OUTPUT "
59+ echo "date= $(date +'%Y-%m-%d_%H:%M:%S')" >> "$GITHUB_OUTPUT "
60+ echo "repository_name= $(echo ${{ github.repository }} | sed -e 's/${{ github.repository_owner }}\///')" >> "$GITHUB_OUTPUT "
6261
63- # Build and Push Docker image to Docker Hub
6462 - name : Build and Push Docker image to Docker Hub
6563 uses : docker/build-push-action@v5
6664 with :
@@ -79,73 +77,37 @@ jobs:
7977 GIT_HASH=${{ github.sha }}
8078 IMAGE_BUILD_DATETIME=${{ steps.info.outputs.date }}
8179
82- # Create git tag
8380 - name : Create and push git tag
8481 run : |
8582 git tag ${{ steps.info.outputs.TAG }}
8683 git push origin ${{ steps.info.outputs.TAG }}
8784
88- # Notify to Slack (Success)
89- - name : Notify deployment to Slack
90- if : failure() || cancelled()
91- uses : slackapi/slack -github-action@v1.26.0
85+ # Trigger infrastructure repo to bump tag and run ansible deploy.
86+ - name : Generate infrastructure deploy token
87+ id : deploy-token
88+ uses : actions/create -github-app-token@v3
9289 with :
93- channel-id : ${{ vars.SLACK_DEPLOYMENT_ALERT_CHANNEL }}
94- payload : |
95- {
96- "blocks": [
97- {
98- "type": "header",
99- "text": {
100- "type": "plain_text",
101- "text": "${{ steps.info.outputs.repository_name }} ${{ steps.info.outputs.TAG }} 버전 Build & Push 실패 :rotating_light: (${{ job.status }})",
102- "emoji": true
103- }
104- },
105- {
106- "type": "section",
107- "text": {"type": "mrkdwn", "text": "GitHub Action 바로가기"},
108- "accessory": {
109- "type": "button",
110- "text": {"type": "plain_text", "text": "${{ github.run_id }}"},
111- "value": "github_action",
112- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
113- "action_id": "button-action"
114- }
115- }
116- ]
117- }
90+ client-id : ${{ vars.DEPLOY_APP_CLIENT_ID }}
91+ private-key : ${{ secrets.DEPLOY_APP_PRIVATE_KEY }}
92+ owner : ${{ github.repository_owner }}
93+ repositories : ${{ secrets.INFRA_REPO_NAME }}
94+
95+ - name : Trigger infrastructure deploy
11896 env :
119- SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
97+ GH_TOKEN : ${{ steps.deploy-token.outputs.token }}
98+ INFRA_REPO : ${{ github.repository_owner }}/${{ secrets.INFRA_REPO_NAME }}
99+ SERVICE : backend-${{ env.API_STAGE }}
100+ IMAGE_TAG : ${{ steps.info.outputs.TAG }}
101+ run : |
102+ gh api "repos/$INFRA_REPO/dispatches" \
103+ --method POST \
104+ -f event_type=bump-image \
105+ -f "client_payload[service]=$SERVICE" \
106+ -f "client_payload[image_tag]=$IMAGE_TAG"
120107
121- # Notify to Slack (Failure)
122- - name : Notify deployment to Slack
123- uses : slackapi/slack-github-action@v1.26.0
108+ - uses : ./.github/actions/notify-slack-deploy
109+ if : always()
124110 with :
125- channel-id : ${{ vars.SLACK_DEPLOYMENT_ALERT_CHANNEL }}
126- payload : |
127- {
128- "blocks": [
129- {
130- "type": "header",
131- "text": {
132- "type": "plain_text",
133- "text": "${{ steps.info.outputs.repository_name }} ${{ steps.info.outputs.TAG }} 버전 Build & Push 성공 :tada:",
134- "emoji": true
135- }
136- },
137- {
138- "type": "section",
139- "text": {"type": "mrkdwn", "text": "GitHub Action 바로가기"},
140- "accessory": {
141- "type": "button",
142- "text": {"type": "plain_text", "text": "${{ github.run_id }}"},
143- "value": "github_action",
144- "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
145- "action_id": "button-action"
146- }
147- }
148- ]
149- }
150- env :
151- SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
111+ slack-token : ${{ secrets.SLACK_BOT_TOKEN }}
112+ slack-channel : ${{ vars.SLACK_DEPLOYMENT_ALERT_CHANNEL }}
113+ header-prefix : " ${{ steps.info.outputs.repository_name }} ${{ steps.info.outputs.TAG }} 버전 Build & Push"
0 commit comments