Try tagging without docker.io/ #4
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
# https://docs.docker.com/build/ci/github-actions/multi-platform/ | |
name: CI | |
on: | |
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#push | |
push: | |
tags: | |
# match on year.month[.day]: YY.MM[.dd] | |
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet | |
- '[2-9][0-9].[0-1][0-9].?[0-3]?[0-9]?' | |
env: | |
IMAGE_LABELS: |- | |
org.opencontainers.image.authors=Erhhung Yuan <[email protected]> | |
jobs: | |
# because env cannot be passed to reusable workflows: | |
# https://github.com/orgs/community/discussions/26671 | |
env-vars: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set env Variables as Outputs | |
run: '#' | |
outputs: | |
image-labels: ${{ env.IMAGE_LABELS }} | |
launch-runner: | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/aws-actions/configure-aws-credentials | |
- name: Configure AWS Credentials | |
id: aws | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.RUNNER_AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# https://github.com/erhhung/ec2-github-runner | |
- name: Launch Temporary EC2 Runner | |
id: runner | |
uses: erhhung/ec2-github-runner@v3 | |
env: | |
RUN_INFO: ${{ github.run_id }}-${{ github.run_attempt }} | |
with: | |
mode: start | |
github-token: ${{ secrets.RUNNER_GITHUB_REPOS_PAT }} | |
labels: Linux,ARM64,AL2023 | |
image-id: ${{ vars.RUNNER_ARM64_AMI_ID }} | |
# runner could lose connection to GitHub Actions | |
# if using instance type smaller than t4g.xlarge | |
instance-type: ${{ vars.RUNNER_ARM64_INSTANCE_TYPE }} | |
spot-instance: 'true' | |
root-volume-size: '${{ vars.RUNNER_ROOT_VOLUME_SIZE }}' | |
subnet-id: ${{ vars.RUNNER_SUBNET_ID }} | |
security-group-id: ${{ vars.RUNNER_SECURITY_GROUP_ID }} | |
iam-role-name: ${{ vars.RUNNER_INSTANCE_ROLE_NAME }} | |
aws-resource-tags: >- | |
[ | |
{"Key": "Name", "Value": "github-runner-${{ env.RUN_INFO }}"}, | |
{"Key": "GitHubRepo", "Value": "${{ github.repository }}"} | |
] | |
pre-runner-script: |- | |
hostname="runner-$(date '+%y%m%d%H%M')-${{ env.RUN_INFO }}" && \ | |
hostnamectl set-hostname $hostname # host name == runner name | |
# iptables is required to set up Docker | |
# libicu is required by GHA Dotnet Core | |
dnf update && dnf install -y git iptables libicu | |
- name: Prepare Job Output Values | |
id: output | |
run: |- | |
csv="self-hosted,${{ steps.runner.outputs.labels }}" | |
cat <<EOF >> $GITHUB_OUTPUT | |
labels-csv=$csv | |
labels-json=["${csv//,/\",\"}"] | |
EOF | |
outputs: | |
runner-name: ${{ steps.runner.outputs.runner-name }} | |
instance-id: ${{ steps.runner.outputs.instance-id }} | |
labels-json: '${{ steps.output.outputs.labels-json }}' | |
labels-csv: '${{ steps.output.outputs.labels-csv }}' | |
build-amd64: | |
needs: env-vars | |
uses: ./.github/workflows/build.yml | |
with: | |
platform: linux/amd64 | |
image-labels: ${{ needs.env-vars.outputs.image-labels }} | |
secrets: inherit | |
build-arm64: | |
needs: | |
- launch-runner | |
- env-vars | |
uses: ./.github/workflows/build.yml | |
with: | |
platform: linux/arm64 | |
runs-on: ${{ needs.launch-runner.outputs.labels-json }} | |
image-labels: ${{ needs.env-vars.outputs.image-labels }} | |
secrets: inherit | |
merge: | |
needs: | |
- build-amd64 | |
- build-arm64 | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/actions/download-artifact | |
- name: Download Digests | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
# https://github.com/crazy-max/ghaction-setup-docker | |
- name: Set up Docker Daemon | |
id: docker | |
uses: crazy-max/ghaction-setup-docker@v3 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker BuildX | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
# https://github.com/docker/metadata-action | |
- name: Extract Metadata for Docker | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: |- | |
${{ github.repository }} | |
ghcr.io/${{ github.repository }} | |
labels: ${{ env.IMAGE_LABELS }} | |
# https://github.com/docker/login-action | |
- name: Log in to Docker Hub | |
id: docker-hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
# https://github.com/docker/login-action | |
- name: Log in to GitHub GHCR | |
id: ghcr | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Create Manifests and Push | |
id: manifests | |
working-directory: /tmp/digests | |
run: |- | |
tags=($(jq -cr '[.tags[] | "-t \(.)"] | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")) | |
images=($(printf '${{ github.repository }}@sha256:%s ' *)) | |
docker buildx imagetools create "${tags[@]}" "${images[@]}" | |
# confirm merged image manifests | |
- name: Inspect Image | |
id: inspect | |
run: |- | |
tag="${{ github.repository }}:$DOCKER_METADATA_OUTPUT_VERSION" | |
docker buildx imagetools inspect $tag | |
terminate-runner: | |
if: always() | |
needs: | |
- launch-runner | |
- build-arm64 | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/aws-actions/configure-aws-credentials | |
- name: Configure AWS Credentials | |
id: aws | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.RUNNER_AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# https://github.com/erhhung/ec2-github-runner | |
- name: Terminate Temporary EC2 Runner | |
id: runner | |
uses: erhhung/ec2-github-runner@v3 | |
with: | |
mode: stop | |
github-token: ${{ secrets.RUNNER_GITHUB_REPOS_PAT }} | |
labels: ${{ needs.launch-runner.outputs.labels-csv }} | |
instance-id: ${{ needs.launch-runner.outputs.instance-id }} |