attempt to fix up docker push action (#244) #38
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: | |
# Publish `master` as Docker `it's short sha commit id` image. | |
branches: | |
- master | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
env: | |
IMAGE_NAME: escalator | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set short sha variable | |
id: vars | |
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
# Log in to GitHub Container registry | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image to GitHub Container Registry | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Use Docker `short_sha` tag convention | |
[ "$VERSION" == "master" ] && VERSION="${{ steps.vars.outputs.sha_short }}" | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
for ARCH in amd64 arm64; do | |
# Disable provenance, as this causes issues when creating the manifest | |
# See https://github.com/atlassian/escalator/issues/219 | |
docker buildx build --provenance=false -t $IMAGE_ID:$VERSION-$ARCH --platform=linux/${ARCH} --push . | |
done | |
docker manifest create $IMAGE_ID:$VERSION \ | |
$(for ARCH in amd64 arm64; do echo $IMAGE_ID:$VERSION-$ARCH; done) | |
docker manifest push $IMAGE_ID:$VERSION |