-
Notifications
You must be signed in to change notification settings - Fork 5
70 lines (68 loc) · 2.5 KB
/
build_and_push_image.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
name: Build and push docker images
on:
workflow_call:
inputs:
build_tag:
description: Docker tag for the built image
required: true
type: string
push_cache:
description: Should the build cache be pushed to the repository?
default: false
required: false
type: boolean
tag_latest:
description: Should the image be tagged with "latest" in addition to the build tag
default: false
required: false
type: boolean
suffix:
description: Image suffix, should be "tools" or "kubectl"
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
build-and-push-image:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Buildx
id: buildx
uses: docker/[email protected]
- name: Show Buildx platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# only push cache to Dockerhub as ECR doesn't support it yet
# https://github.com/aws/containers-roadmap/issues/876
- name: Build and push image build cache to Docker Hub
if: ${{ inputs.push_cache }}
run: make push-image-cache-${{ inputs.suffix }}
- name: Build and push image to Docker Hub
run: make push-image-${{ inputs.suffix }} BUILD_TAG=${{ inputs.build_tag }}
- name: Tag latest to point to most recent release in Docker Hub
if: ${{ inputs.tag_latest }}
run: make tag-release-image-with-latest-${{ inputs.suffix }} BUILD_TAG=${{ inputs.build_tag }}
- name: Login to ECR
run: make login-ecr
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push image to ECR
run: make push-image-ecr-${{ inputs.suffix }} BUILD_TAG=${{ inputs.build_tag }}
- name: Tag latest to point to most recent release in ECR
if: ${{ inputs.tag_latest }}
run: make tag-release-image-with-latest-ecr-${{ inputs.suffix }} BUILD_TAG=${{ inputs.build_tag }}