-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (56 loc) · 2.05 KB
/
develop_deploy.yml
File metadata and controls
61 lines (56 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: develop Deploy
on:
# 워크플로우를 수동으로 트리거, 수동 배포
workflow_dispatch:
inputs:
commit_hash:
description: "commit hash"
required: true
env:
DOCKERHUB_USERNAME: ject4tserver
DOCKERHUB_IMAGE_NAME: studytrip-server
jobs:
deploy:
runs-on: ubuntu-latest
environment: DEV
steps:
- name: Deploy to EC2 Server
uses: appleboy/ssh-action@v1.0.3
env:
DOCKERHUB_IMAGE_FULL_PATH: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.event.inputs.commit_hash }}
DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }}
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: DOCKERHUB_IMAGE_FULL_PATH, DOCKERHUB_IMAGE_NAME
debug: true
script: |
echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker compose up -d
docker image prune -a -f
# 슬랙으로 알림 전송
- name: Send to slack notification
uses: slackapi/slack-github-action@v2.1.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: "Build and Deploy result"
blocks:
- type: section
text:
type: mrkdwn
text: "*✅ 배포 완료 알림*"
- type: section
text:
type: mrkdwn
text: "*실행 로그:* 🔗 <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>"
- type: context
elements:
- type: mrkdwn
text: "*브랜치:* `${{ github.ref_name }}`"
- type: mrkdwn
text: "*커밋:* `${{ github.event.inputs.commit_hash }}`"
- type: divider