Skip to content

Merge pull request #1239 from Shelf-nu/adjust-url-shortener-middleware #455

Merge pull request #1239 from Shelf-nu/adjust-url-shortener-middleware

Merge pull request #1239 from Shelf-nu/adjust-url-shortener-middleware #455

Workflow file for this run

name: 🐳 Create and publish a Docker image
on:
push:
branches:
- main
- dev
permissions:
actions: write
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: 🐳 Build
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
- name: ⬇️ Checkout repo
uses: actions/[email protected]
- name: 🥡 Set up QEMU
uses: docker/[email protected]
- name: ✖️ Set up Docker Buildx
uses: docker/[email protected]
- name: ⚡️ Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: 👋 Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🧪 Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=ref,enable=${{ github.ref_type != 'tag' }},suffix=-{{sha}},event=branch
type=ref,event=tag
- name: 🛠 Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: Dockerfile.image
platforms: linux/amd64,linux/arm64
push: true
# Note: provenance fixes unknown/unknown platform to be generated on build
# https://github.com/orgs/community/discussions/45969#discussioncomment-8170787
# https://github.com/docker/build-push-action/issues/820#issuecomment-1445131521
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
COMMIT_SHA=${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
- name: 🚚 Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache