-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (76 loc) · 2.93 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
name: Deploy Lambda
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: 'Environment'
required: true
options:
- intg
- staging
- prod
default: 'intg'
toDeploy:
description: 'Version to deploy'
required: true
permissions:
id-token: write
contents: write
actions: write
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.WORKFLOW_PAT }}
- name: Configure AWS credentials from management account
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_NUMBER }}:role/TDRGithubActionsDeployLambda${{ secrets.TITLE_STAGE }}
aws-region: eu-west-2
role-session-name: DeployLambda
- name: Deploy lambda
run: |
aws lambda update-function-code --function-name tdr-create-keycloak-user-s3-${{ github.event.inputs.environment }} --s3-bucket tdr-backend-code-mgmt --s3-key ${{ github.event.inputs.toDeploy }}/keycloak-user-management.jar > /dev/null
aws lambda update-function-code --function-name tdr-create-keycloak-user-api-${{ github.event.inputs.environment }} --s3-bucket tdr-backend-code-mgmt --s3-key ${{ github.event.inputs.toDeploy }}/keycloak-user-management.jar > /dev/null
- name: Send service updated message
uses: slackapi/[email protected]
with:
payload: |
{
"service" : "Keycloak user management",
"version" : "${{ github.event.inputs.toDeploy }}",
"environment": "${{ github.event.inputs.environment }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SUCCESS_WORKFLOW }}
- name: Update release branch
run: |
git branch -f release-${{ github.event.inputs.environment }} HEAD
git push -f origin release-${{ github.event.inputs.environment }}
- name: Run E2E tests
if: github.event.inputs.environment != 'prod'
uses: octokit/[email protected]
with:
route: POST /repos/nationalarchives/tdr-e2e-tests/actions/workflows/ci.yml/dispatches
ref: master
inputs: "{\"environment\": \"${{ github.event.inputs.environment }}\"}"
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }}
- name: Send failure message
id: slack
uses: slackapi/[email protected]
if: ${{ failure() }}
with:
payload: |
{
"service" : "Keycloak user management",
"version" : "${{ github.event.inputs.toDeploy }}",
"environment": "${{ github.event.inputs.environment }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_FAILURE_WORKFLOW }}