-
Notifications
You must be signed in to change notification settings - Fork 44
99 lines (95 loc) · 3.95 KB
/
redshift-ded.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
name: Redshift dedicated env
on:
pull_request:
types: [closed, unlabeled, labeled, synchronize]
env:
NODE_VERSION: 14
PYTHON2_VERSION: 2.7.18
PYTHON3_VERSION: 3.8.10
VIRTUALENV_VERSION: 20.15.1
jobs:
dedicated:
if: |
github.event.label.name == 'dedicated_redshift' ||
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'dedicated_redshift')) ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'dedicated_redshift'))
runs-on: ubuntu-20.04
container: python:2.7.18-buster
timeout-minutes: 20
env:
RS_HOST: ${{ secrets.RS_HOST_CD }}
RS_DATABASE: ${{ secrets.RS_DATABASE_CD }}
RS_USER: ${{ secrets.RS_USER_CD }}
RS_PASSWORD: ${{ secrets.RS_PASSWORD_CD }}
RS_BUCKET: ${{ secrets.RS_BUCKET_CD }}
AWS_ACCESS_KEY_ID: ${{ secrets.RS_AWS_ACCESS_KEY_ID_CD }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RS_AWS_SECRET_ACCESS_KEY_CD }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Check diff
uses: technote-space/get-diff-action@v4
- name: Set RS_PREFIX for releases
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: |
echo "RS_PREFIX=dedicated_release_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Set RS_PREFIX for hotfixes
if: startsWith(github.event.pull_request.head.ref, 'hotfix/')
run: |
echo "RS_PREFIX=dedicated_hotfix_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Set RS_PREFIX for the rest
if: |
!(startsWith(github.event.pull_request.head.ref, 'hotfix/')) &&
!(startsWith(github.event.pull_request.head.ref, 'release/'))
run: echo "RS_PREFIX=dedicated_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup yarn
run: npm install -g yarn
- name: Install dependencies
run: |
apt-get update
apt-get -y install rsync zip unzip curl glibc-source groff less
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.RS_AWS_ACCESS_KEY_ID_CD }}
aws-secret-access-key: ${{ secrets.RS_AWS_SECRET_ACCESS_KEY_CD }}
aws-region: ${{ secrets.RS_REGION_CD }}
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Run deploy
id: deploy
if: github.event.action == 'synchronize' || github.event.action == 'labeled'
run: |
cd clouds/redshift
make deploy dropfirst=1
- name: Run remove
id: remove
if: github.event.action == 'unlabeled' || github.event.action == 'closed'
run: |
cd clouds/redshift
make remove
- name: Comment deploy PR
if: steps.deploy.outcome == 'success' && github.event.action == 'labeled'
uses: thollander/actions-comment-pull-request@v1
with:
message: |
Dedicated ${{ env.RS_PREFIX }}carto environment deployed in Redshift host ${{ env.RS_HOST }} and ${{ env.RS_DATABASE }} database
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment remove PR
if: steps.remove.outcome == 'success' && (github.event.action == 'unlabeled' || github.event.action == 'closed')
uses: thollander/actions-comment-pull-request@v1
with:
message: |
Dedicated environment removed
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}