-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (147 loc) · 6.14 KB
/
release.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
name: release
on:
workflow_dispatch:
inputs:
environment:
description: Environment to release
required: true
default: production
ref:
description: Ref to release
required: true
default: master
repository_dispatch:
types:
- release
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.ref }}${{ github.event.client_payload.ref }}
- name: Start deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
env: ${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }}
desc: ${{ github.event.client_payload.ref }}${{ github.event.client_payload.ref }}
ref: ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Node modules cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile --non-interactive
- name: Move runtime dependencies
run: |
version=$(jq -r '.devDependencies."@pureskillgg/awsjs"' < package.json)
yarn remove @pureskillgg/awsjs
yarn add "@pureskillgg/awsjs@${version}"
- name: Serverless deploy to production from ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }}
run: yarn run deploy
if: ${{ github.event.inputs.environment == 'production' || github.event.client_payload.environment == 'production' }}
env:
SERVERLESS_STAGE: prod
- name: Serverless deploy to staging from ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }}
run: yarn run deploy
if: ${{ github.event.inputs.environment == 'staging' || github.event.client_payload.environment == 'staging' }}
env:
SERVERLESS_STAGE: stg
- name: Get commit message
id: message
run: echo ::set-output name=message::$(git log --format=%B -n 1 ${{ github.sha }})
- name: Grafana Annotation
uses: frankie567/[email protected]
with:
apiHost: ${{ secrets.GRAFANA_API_ORIGIN }}
apiToken: ${{ secrets.GRAFANA_API_KEY }}
tags: deployment,${{ github.event.repository.name }},${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }}
text: |
${{ steps.message.outputs.message }}
${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }}
${{ github.sha }}
- name: Get version
id: version
run: |
echo "::set-output name=version::$(jq -r .version < package.json)"
- name: Sentry release v${{ steps.version.outputs.version }} to production
if: ${{ github.event.inputs.environment == 'production' || github.event.client_payload.environment == 'production' }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ github.repository_owner }}
SENTRY_PROJECT: ${{ github.event.repository.name }}
with:
environment: prod
version: ${{ steps.version.outputs.version }}
version_prefix: ${{ github.event.repository.name }}@
- name: Sentry release v${{ steps.version.outputs.version }} to staging
if: ${{ github.event.inputs.environment == 'staging' || github.event.client_payload.environment == 'staging' }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ github.repository_owner }}
SENTRY_PROJECT: ${{ github.event.repository.name }}
with:
environment: stg
version: ${{ steps.version.outputs.version }}
version_prefix: ${{ github.event.repository.name }}@
- name: Get status
id: status
if: always()
run: |
if [ "${JOB_STATUS,,}" == 'success' ]; then
echo "::set-output name=color::#00ff00"
else
echo "::set-output name=color::#ff0000"
fi
env:
JOB_STATUS: ${{ job.status }}
- name: Notify Discord
uses: rtCamp/action-slack-notify@v2
if: always()
env:
SLACK_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}/slack
SLACK_USERNAME: PureSkill.gg Bot
SLACK_ICON_EMOJI: ':github:'
SLACK_COLOR: ${{ steps.status.outputs.color }}
SLACK_ICON: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
SLACK_TITLE: Deployed ${{ github.event.inputs.environment }}${{ github.event.client_payload.environment }}
SLACK_MESSAGE: ${{ github.event.client_payload.ref }}${{ github.event.inputs.ref }}
SLACK_FOOTER: ${{ github.repository }}
- name: Finish deployment
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
token: ${{ secrets.GITHUB_TOKEN }}