-
Notifications
You must be signed in to change notification settings - Fork 6
131 lines (121 loc) Β· 5.32 KB
/
deploy.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
name: deploy
on:
workflow_dispatch:
inputs:
# Branch is chosen by default in github manual actions
environment:
description: playground, staging or prod for worker and web or exact Env name like iaso-stg-worker
required: true
slack_channel:
description: Slack Channel for notification (iasops by default)
required: false
default: iasops
push:
# On push to main deploy to staging
branches:
- main
jobs:
build:
runs-on: ubuntu-20.04
steps:
# Merge the workflow_dispatch config with some default for deployment via the on:push
- name: Set configs
id: config
env:
DEFAULT_GIT_REFERENCE: main
DEFAULT_ENVIRONMENT: staging
DEFAULT_SLACK_CHANNEL: iasops
run: |
echo "::set-output name=GIT_REFERENCE::${{ github.ref_name || env.DEFAULT_GIT_REFERENCE }}"
echo "::set-output name=ENVIRONMENT::${{ github.event.inputs.environment || env.DEFAULT_ENVIRONMENT }}"
echo "::set-output name=SLACK_CHANNEL::${{ github.event.inputs.slack_channel || env.DEFAULT_SLACK_CHANNEL }}"
- uses: actions/checkout@v2
with:
ref: ${{ steps.config.outputs.GIT_REFERENCE }}
fetch-depth: 0
- name: Deployment of ${{ github.ref_name }} on ${{ steps.config.outputs.ENVIRONMENT }}
id: version
run: |
export GITHUB_BRANCH=${GITHUB_REF##*heads/}
echo $GITHUB_BRANCH
git describe --tags
echo "::set-output name=VERSION_NAME::$(git describe --tags --match "v[[:digit:]]*")"
- name: Slack deployement start
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_COLOR: ""
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Started deployement of ${{ steps.version.outputs.VERSION_NAME }} on ${{ steps.config.outputs.ENVIRONMENT }} ...
SLACK_FOOTER: ${{ format('<https://github.com/{0}/commit/{1}/checks|π{2} logs> | <https://github.com/{0}/commit/{1}/checks|π Commit {1}>', github.repository, github.sha, github.job) }}
MSG_MINIMAL: true
- name: Use node.js 20
uses: actions/setup-node@v2
with:
node-version: '20.13.1'
- name: upgrade npm
run: |
npm install --global [email protected]
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Setup beanstalk
# the specification of botocore is due to a deployment problem with 1.21 to remove later
run: |
cp .elasticbeanstalk/config.github.yml .elasticbeanstalk/config.yml
pip install awsebcli==3.20.5 botocore==1.29.81 boto3==1.26.81
- name: Environment info
run: |
node --version
npm --version
pip list
- name: npm ci
run: |
npm ci
- name: npm build
run: |
rm -f hat/assets/webpack/*
npm run webpack-prod
git add -f hat/assets/webpack/
# add version in python
scripts/set_version.sh
git add -f hat/__version__.py
env:
VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
CI: false
- name: deploy to beanstalk
run: python scripts/eb_deploy.py ${{ steps.config.outputs.ENVIRONMENT }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-central-1"
VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
- name: Slack deployement success notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_COLOR: ${{ job.status }}
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Iaso ${{ steps.version.outputs.VERSION_NAME }} successfully deployed on ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_MESSAGE: ${{ format('<https://github.com/{0}/commit/{1}/checks|π{2} logs> | <https://github.com/{0}/commit/{1}/checks|π Commit {1}>', github.repository, github.sha, github.job) }}
SLACK_FOOTER: "-"
MSG_MINIMAL: true
if: success()
- name: Slack deployement failure notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ steps.config.outputs.SLACK_CHANNEL }}
SLACK_USERNAME: ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_COLOR: ${{ job.status }}
SLACK_ICON_EMOJI: ":robot_face:"
SLACK_TITLE: Deployment failure Iaso ${{ steps.version.outputs.VERSION_NAME }} - ${{ steps.config.outputs.ENVIRONMENT }}
SLACK_MESSAGE: ${{ format('<https://github.com/{0}/commit/{1}/checks|π{2} logs> | <https://github.com/{0}/commit/{1}/checks|π Commit {1}>', github.repository, github.sha, github.job) }}
SLACK_FOOTER: "-"
MSG_MINIMAL: true
if: failure()