Skip to content

Commit

Permalink
Rewrite docker workflow. (#994)
Browse files Browse the repository at this point in the history
* Rewrite docker workflow.

* tidy

* Create 994.misc

Signed-off-by: Will Hunt <will@half-shot.uk>

---------

Signed-off-by: Will Hunt <will@half-shot.uk>
  • Loading branch information
Half-Shot authored Nov 29, 2024
1 parent 819c089 commit d550077
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 103 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/docker-hub-latest.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/docker-hub-release.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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 }}
1 change: 1 addition & 0 deletions changelog.d/994.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Push Docker images to ghcr.io, and and build an image on each commit.

0 comments on commit d550077

Please sign in to comment.