-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (72 loc) · 2.68 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
name: Deploy
on:
push:
branches:
- "main"
- "vsl"
jobs:
check-skip-deploy:
runs-on: ubuntu-latest
outputs:
skip-deploy: ${{ steps.check-skip-label.outputs.skip-deploy }}
steps:
- name: Check if the commit should be deployed
id: check-skip-label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SKIP_DEPLOY=false
# Get the PR number where the commit was introduced in
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --search ${{ github.sha }} --state merged --json number --jq '.[0].number')
echo "The commit was introduced in PR $PR_NUMBER".
if [ -n "$PR_NUMBER" ]; then
LABELS=$(gh pr view --repo ${{ github.repository }} $PR_NUMBER --json labels --jq '.labels[].name')
echo "The PR has the following labels: $(echo "$LABELS" | sed 's/^\|$/"/g' | paste -sd, -)."
if echo "$LABELS" | grep -q "skip deploy"; then
SKIP_DEPLOY=true
fi
fi
echo "skip-deploy=$SKIP_DEPLOY" >> $GITHUB_OUTPUT
echo "skip-deploy: $SKIP_DEPLOY"
define-environment:
runs-on: ubuntu-latest
needs: check-skip-deploy
if: ${{ needs.check-skip-deploy.outputs.skip-deploy == 'false' }}
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- name: Set environment
id: set-env
run: |
if [ "${{ github.ref }}" = "refs/heads/vsl" ]; then
ENVIRONMENT=vsl-test
else
ENVIRONMENT=arho-test
fi
echo "environment=$ENVIRONMENT" >> $GITHUB_OUTPUT
build-and-deploy-lambda-functions:
runs-on: ubuntu-latest
needs: define-environment
environment: ${{ needs.define-environment.outputs.environment }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Copy .env file
run: cp .env.dev .env
- name: Build zip files for lambda
run: make build-lambda
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_LAMBDA_UPLOAD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_LAMBDA_UPLOAD_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Update dev lambda functions
run: make prefix=${{ vars.INFRA_PREFIX }} update-lambda -C infra
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
- name: Update dev database
run: make prefix=${{ vars.INFRA_PREFIX }} migrate-db -C infra