-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (91 loc) · 3.4 KB
/
docker-publish.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
94
95
96
97
98
99
100
101
name: Docker
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
env:
IMAGE_NAME: docker-alpine-aws-cli
PLATFORM: "linux/amd64,linux/arm64"
jobs:
test-multiarch:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
strategy:
matrix:
tag:
# To keep the number of builds low, we only keep the latest two versions of the AWS CLI
- 2.15.0-3.18
- 2.15.0-3.17
- 2.15.0-3.16
- 2.13.18-3.18
- 2.13.18-3.17
- 2.13.18-3.16
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Only build the images
run: |
AWS_CLI_VERSION="$(echo "${{ matrix.tag }}" | awk '{split($0,a,"-"); print a[1]}')"
ALPINE_VERSION="$(echo "${{ matrix.tag }}" | awk '{split($0,a,"-"); print a[2]}')"
AUTHOR=$(echo "${{ github.repository_owner }}" | tr '[A-Z]' '[a-z]')
# Build process
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:${AWS_CLI_VERSION}-alpine${ALPINE_VERSION}
# Change all uppercase to lowercase.
IMAGE_ID=$(echo "${IMAGE_ID}" | tr '[A-Z]' '[a-z]')
echo "IMAGE_ID=${IMAGE_ID}"
docker buildx build . \
--platform "${PLATFORM}" \
--build-arg AUTHOR=${AUTHOR} \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
--build-arg AWS_CLI_VERSION=${AWS_CLI_VERSION} \
-t ${IMAGE_ID}
deploy-multiarch:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
tag:
# To keep the number of builds low, we only keep the latest two versions of the AWS CLI
- 2.15.0-3.18
- 2.15.0-3.17
- 2.15.0-3.16
- 2.13.18-3.18
- 2.13.18-3.17
- 2.13.18-3.16
steps:
- uses: actions/checkout@v3
# Refs https://github.com/docker/login-action#github-container-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push images to GitHub Container Registry
run: |
AWS_CLI_VERSION="$(echo "${{ matrix.tag }}" | awk '{split($0,a,"-"); print a[1]}')"
ALPINE_VERSION="$(echo "${{ matrix.tag }}" | awk '{split($0,a,"-"); print a[2]}')"
AUTHOR=$(echo "${{ github.repository_owner }}" | tr '[A-Z]' '[a-z]')
# Build process
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:${AWS_CLI_VERSION}-alpine${ALPINE_VERSION}
# Change all uppercase to lowercase.
IMAGE_ID=$(echo "${IMAGE_ID}" | tr '[A-Z]' '[a-z]')
echo "IMAGE_ID=${IMAGE_ID}"
docker buildx build --push . \
--platform "${PLATFORM}" \
--build-arg AUTHOR=${AUTHOR} \
--build-arg IMAGE_NAME=${IMAGE_NAME} \
--build-arg ALPINE_VERSION=${ALPINE_VERSION} \
--build-arg AWS_CLI_VERSION=${AWS_CLI_VERSION} \
-t ${IMAGE_ID}