-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (105 loc) · 3.6 KB
/
cdk_release_code.yml
File metadata and controls
115 lines (105 loc) · 3.6 KB
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
name: cdk release code
on:
workflow_call:
inputs:
STACK_NAME:
required: true
type: string
ARTIFACT_BUCKET_PREFIX:
required: true
type: string
TARGET_ENVIRONMENT:
required: true
type: string
BUILD_ARTIFACT:
required: true
type: string
VERSION_NUMBER:
required: true
type: string
COMMIT_ID:
required: true
type: string
pinned_image:
type: string
required: true
IS_PULL_REQUEST:
type: boolean
required: true
secrets:
CLOUD_FORMATION_DEPLOY_ROLE:
required: true
CDK_PULL_IMAGE_ROLE:
required: true
DEV_CLOUD_FORMATION_CHECK_VERSION_ROLE:
required: false
INT_CLOUD_FORMATION_CHECK_VERSION_ROLE:
required: false
PROD_CLOUD_FORMATION_CHECK_VERSION_ROLE:
required: false
DEV_CLOUD_FORMATION_EXECUTE_LAMBDA_ROLE:
required: false
jobs:
release_code:
runs-on: ubuntu-22.04
container:
image: ${{ inputs.pinned_image }}
options: --user 1001:1001 --group-add 128
defaults:
run:
shell: bash
environment: ${{ inputs.TARGET_ENVIRONMENT }}
permissions:
id-token: write
contents: write
steps:
- name: copy .tool-versions
run: |
cp /home/vscode/.tool-versions "$HOME/.tool-versions"
- name: build_artifact download
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: build_artifact
- name: extract build_artifact
run: |
mkdir -p .build
tar -xf artifact.tar
- name: Configure AWS Credentials
id: connect-aws
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
with:
aws-region: eu-west-2
role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }}
role-session-name: aws-dashboards-deployment
output-credentials: true
- name: Deploy code
run: npm run cdk-deploy --workspace packages/cdk
shell: bash
env:
CDK_APP_NAME: DashboardsApp
CDK_STACK_NAME: "DashboardsStack"
CDK_CONFIG_dashboardStackName: ${{ inputs.STACK_NAME }}
CDK_CONFIG_versionNumber: ${{ inputs.VERSION_NUMBER }}
CDK_CONFIG_commitId: ${{ inputs.COMMIT_ID }}
CDK_CONFIG_isPullRequest: ${{ inputs.IS_PULL_REQUEST }}
CDK_CONFIG_environment: ${{ inputs.TARGET_ENVIRONMENT }}
- name: Checkout gh-pages
if: ${{ !startsWith(inputs.STACK_NAME, 'lambda-resources-pr-') }}
uses: actions/checkout@v6.0.2
with:
ref: gh-pages
path: gh-pages
- name: update release tag in github pages
if: ${{ inputs.TARGET_ENVIRONMENT != 'dev-pr' }}
run: |
cd gh-pages
NOW=$(date +'%Y-%m-%dT%H:%M:%S')
echo "tag,release_datetime" > _data/${{ inputs.TARGET_ENVIRONMENT }}_latest.csv
echo "${{ inputs.VERSION_NUMBER }},${NOW}" >> _data/${{ inputs.TARGET_ENVIRONMENT }}_latest.csv
echo "${{ inputs.VERSION_NUMBER }},${NOW}" >> _data/${{ inputs.TARGET_ENVIRONMENT }}_deployments.csv
git config user.name github-actions
git config user.email github-actions@github.com
git add _data/${{ inputs.TARGET_ENVIRONMENT }}_latest.csv
git add _data/${{ inputs.TARGET_ENVIRONMENT }}_deployments.csv
git commit -m 'update releases for ${{ inputs.TARGET_ENVIRONMENT }}'
parallel --retries 10 --delay 3 ::: "git pull --rebase && git push"