refs platform/#2581: keep documentation and completer in the final image #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |