-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (79 loc) · 3.52 KB
/
main.yml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: deploy
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get commit message and author
id: get_commit_info
run: |
echo "::set-output name=message::$(git log --format=%s -n 1)"
echo "::set-output name=author::$(git log --format=%an -n 1)"
echo "::set-output name=author_username::$(git log --format=%ae -n 1 | cut -d@ -f1)"
- name: Install dependencies
run: yarn install
- name: Generate build
id: build
env:
VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }}
VITE_OAUTH_KAKAO_REST_API_KEY: ${{ secrets.VITE_OAUTH_KAKAO_REST_API_KEY }}
VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE: ${{ secrets.VITE_OAUTH_KAKAO_CLIENT_SECRET_CODE }}
VITE_OAUTH_KAKAO_REDIRECT_URI: ${{ secrets.VITE_OAUTH_KAKAO_REDIRECT_URI }}
run: yarn build
continue-on-error: true
- name: Deploy to S3
id: deploy
if: steps.build.outcome == 'success'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws s3 sync --region ap-northeast-2 dist s3://alignlab-client --delete
continue-on-error: true
- name: Invalidate CloudFront Cache
if: steps.deploy.outcome == 'success'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
run: |
aws cloudfront create-invalidation --region ap-northeast-2 --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
- name: Discord notification - Success
if: steps.deploy.outcome == 'success'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
DISCORD_USERNAME: GitHub
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
uses: Ilshidur/action-discord@master
with:
args: |
🎉 배포가 성공적으로 완료되었습니다!
브랜치: develop
커밋: ${{ steps.get_commit_info.outputs.message }}
작성자: ${{ steps.get_commit_info.outputs.author }}
- name: Discord notification - Failure
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DEPLOY_WEBHOOK }}
DISCORD_USERNAME: GitHub
DISCORD_AVATAR: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
uses: Ilshidur/action-discord@master
with:
args: |
❌ ${{ steps.build.outcome == 'failure' && '빌드 중' || '배포 중' }} 오류가 발생했습니다.
브랜치: develop
커밋: ${{ steps.get_commit_info.outputs.message }}
작성자: <@${{ secrets.DISCORD_ID_1 }}>
실패한 워크플로우: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
${{ steps.build.outcome == 'failure' && '빌드 오류 메시지:' || '' }}
${{ steps.build.outcome == 'failure' && steps.build.outputs.stderr || '' }}
- name: Check deploy result
if: steps.build.outcome == 'failure' || steps.deploy.outcome == 'failure'
run: exit 1