-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (75 loc) · 2.77 KB
/
docker_image_upload.yml
File metadata and controls
86 lines (75 loc) · 2.77 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
name: docker image upload
on:
workflow_call:
inputs:
VERSION_NUMBER:
required: true
type: string
COMMIT_ID:
required: true
type: string
AWS_ENVIRONMENT:
required: true
type: string
TAG_LATEST:
required: true
type: boolean
DOCKER_IMAGE_TAG:
required: true
type: string
secrets:
CDK_PUSH_IMAGE_ROLE:
required: true
jobs:
upload_docker_image:
runs-on: ubuntu-22.04
environment: ${{ inputs.AWS_ENVIRONMENT }}
permissions:
id-token: write
contents: write
steps:
- name: Checkout local github actions
uses: actions/checkout@v5
with:
ref: ${{ env.BRANCH_NAME }}
fetch-depth: 0
sparse-checkout: |
.github
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: eu-west-2
role-to-assume: ${{ secrets.CDK_PUSH_IMAGE_ROLE }}
role-session-name: upload-cdk-utils-build
- name: docker_artifact download
uses: actions/download-artifact@v4
with:
name: docker_artifact
path: .
- name: Extract cdk-utils-build docker image
id: extract-cdk-utils-build-image
run: |
docker load -i cdk-utils-build.img
- name: Retrieve AWS Account ID
id: retrieve-account-id
run: echo "ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_ENV"
- name: Login to Amazon ECR
id: login-ecr
run: |
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com
- name: Push tagged version cdk-utils-build to Amazon ECR
run: |
docker tag "cdk-utils-build:${{ inputs.VERSION_NUMBER }}" "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/cdk-utils-build-repo:${{ inputs.DOCKER_IMAGE_TAG }}"
docker push "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/cdk-utils-build-repo:${{ inputs.DOCKER_IMAGE_TAG }}"
- name: Push latest cdk-utils-build to Amazon ECR
if: ${{ inputs.TAG_LATEST == true }}
run: |
docker tag "cdk-utils-build:${{ inputs.VERSION_NUMBER }}" "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/cdk-utils-build-repo:latest"
docker push "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/cdk-utils-build-repo:latest"
- name: Check cdk-utils-build scan results
env:
REPOSITORY_NAME: cdk-utils-build-repo
IMAGE_TAG: ${{ inputs.DOCKER_IMAGE_TAG }}
working-directory: .github/scripts
run: |
./check_ecr_image_scan_results.sh