Rewrite docker workflow. (#994) #7
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
# Based on https://github.com/matrix-org/dendrite/blob/master/.github/workflows/docker-hub.yml | |
name: "Docker" | |
on: | |
push: | |
paths-ignore: | |
- changelog.d/**' | |
pull_request: | |
branches: [ main ] | |
paths-ignore: | |
- changelog.d/**' | |
release: | |
types: [published] | |
merge_group: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
env: | |
DOCKER_NAMESPACE: halfshot | |
PLATFORMS: linux/amd64 | |
PLATFORMS_PUSH: linux/amd64,linux/arm64 | |
# Only push if this is main, otherwise we just want to build | |
BUILD_FOR_ALL_PLATFORMS: ${{ github.ref == 'refs/heads/main' }} | |
jobs: | |
docker-latest: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Log in to the GitHub Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=branch | |
type=ref,event=pr | |
type=raw,value=latest,enable={{is_default_branch}} | |
images: | | |
${{ env.DOCKER_NAMESPACE }}/matrix-hookshot | |
ghcr.io/matrix-org/matrix-hookshot | |
- name: Build and push Docker images | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
# arm64 builds OOM without the git fetch setting. c.f. | |
# https://github.com/rust-lang/cargo/issues/10583 | |
build-args: | | |
CARGO_NET_GIT_FETCH_WITH_CLI=true | |
platforms: ${{ (env.BUILD_FOR_ALL_PLATFORMS == 'true' && env.PLATFORMS_PUSH) || env.PLATFORMS }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |