Skip to content

Commit 7df0ead

Browse files
committed
feat: 배포 스크립트가 실제 서버에 배포를 하도록 수정
1 parent e95ba6e commit 7df0ead

5 files changed

Lines changed: 78 additions & 190 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Notify Slack of deploy result
2+
description: Send a Slack chat.postMessage reflecting the calling job's status. The status emoji ('성공 :tada:', '취소 :no_entry:', '실패 :rotating_light:') is auto-appended to the header — the caller supplies the prefix.
3+
4+
inputs:
5+
slack-token:
6+
description: Slack bot token (xoxb-...)
7+
required: true
8+
slack-channel:
9+
description: Slack channel ID
10+
required: true
11+
header-prefix:
12+
description: Header text shown before the auto-appended status emoji (e.g. "backend 1.2.3 버전 Build & Push")
13+
required: true
14+
section-text:
15+
description: Section body in mrkdwn. Caller can reference job.status / step outputs to vary by outcome.
16+
required: false
17+
default: GitHub Action 바로가기
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Notify Slack
23+
uses: slackapi/slack-github-action@v3
24+
with:
25+
method: chat.postMessage
26+
token: ${{ inputs.slack-token }}
27+
payload: |
28+
channel: "${{ inputs.slack-channel }}"
29+
blocks:
30+
- type: header
31+
text:
32+
type: plain_text
33+
text: "${{ inputs.header-prefix }} ${{ job.status == 'success' && '성공 :tada:' || job.status == 'cancelled' && '취소 :no_entry:' || '실패 :rotating_light:' }}"
34+
emoji: true
35+
- type: section
36+
text:
37+
type: mrkdwn
38+
text: "${{ inputs.section-text }}"
39+
accessory:
40+
type: button
41+
text:
42+
type: plain_text
43+
text: "${{ github.run_id }}"
44+
value: github_action
45+
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
46+
action_id: button-action

.github/scripts/update_ssm_parameter_store.py

Lines changed: 0 additions & 103 deletions
This file was deleted.

.github/workflows/release-server.yaml

Lines changed: 29 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
type: choice
1515
options:
1616
- dev
17-
- prod
17+
- prd
1818
push:
1919
branches:
2020
- "main"
@@ -28,7 +28,6 @@ jobs:
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"

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ dev = [
4848
"pytest-socket>=0.7.0",
4949
]
5050
deployment = [
51-
"boto3>=1.42.86",
52-
"django>=6.0.4",
53-
"django-environ>=0.13.0",
54-
"django-storages[s3]>=1.14.6",
55-
"djangorestframework>=3.17.1",
56-
"setuptools>=82.0.1",
51+
"packaging>=26.0",
5752
]
5853

5954
[tool.uv]

uv.lock

Lines changed: 2 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)