-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (82 loc) · 2.52 KB
/
auth.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
# For accessing a private registry
name: auth
on:
push:
branches:
- main
- staging
paths:
# Build when there are changes in the directory that holds the component,
# or when this workflow file is changed
- 'auth/**'
- '.github/workflows/auth.yml'
schedule:
# A weekly build to pick up updates to the base container image
# A weekday at mid-day - when someone is likely to be working (avoid bank holidays)
- cron: "0 12 * * 2"
workflow_dispatch:
# Build when shared is built - currently not quite working so we rely on a list of components in shared.yml
workflow_run:
workflows:
- shared
types:
- completed
branches: [ main, staging ]
jobs:
setenv:
name: Determine deployment environment
runs-on: ubuntu-latest
steps:
- name: Set environment name based on branch name
working-directory: ./${{ env.component }}
id: branch_check
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]
then
echo "env_name=production" >> $GITHUB_OUTPUT
elif [ "${{ github.event.workflow_run.head_branch }}" = "main" ]
then
echo "env_name=production" >> $GITHUB_OUTPUT
else
echo "env_name=staging" >> $GITHUB_OUTPUT
fi
outputs:
env_name: ${{ steps.branch_check.outputs.env_name }}
lambda:
name: Deploy Lambda
needs: [setenv]
environment: ${{ needs.setenv.outputs.env_name }}
runs-on: ubuntu-latest
env:
component: auth
lambdaName: ${{ vars.AUTH_LAMBDA }}
steps:
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
registry-url: 'https://npm.pkg.github.com'
- name: Build
working-directory: ./${{ env.component }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn
yarn lint
yarn test
yarn compile
- name: Package
working-directory: ./${{ env.component }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn package
- name: Update Lambda
working-directory: ./${{ env.component }}
run: |
aws lambda update-function-code --function-name=${{ env.lambdaName }} --zip-file fileb://dist/function.zip