Skip to content

Commit d550077

Browse files
authored
Rewrite docker workflow. (#994)
* Rewrite docker workflow. * tidy * Create 994.misc Signed-off-by: Will Hunt <[email protected]> --------- Signed-off-by: Will Hunt <[email protected]>
1 parent 819c089 commit d550077

File tree

4 files changed

+85
-103
lines changed

4 files changed

+85
-103
lines changed

.github/workflows/docker-hub-latest.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/docker-hub-release.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/docker.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Based on https://github.com/matrix-org/dendrite/blob/master/.github/workflows/docker-hub.yml
2+
3+
name: "Docker"
4+
5+
on:
6+
push:
7+
paths-ignore:
8+
- changelog.d/**'
9+
pull_request:
10+
branches: [ main ]
11+
paths-ignore:
12+
- changelog.d/**'
13+
release:
14+
types: [published]
15+
16+
merge_group:
17+
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: false
22+
23+
env:
24+
DOCKER_NAMESPACE: halfshot
25+
PLATFORMS: linux/amd64
26+
PLATFORMS_PUSH: linux/amd64,linux/arm64
27+
# Only push if this is main, otherwise we just want to build
28+
BUILD_FOR_ALL_PLATFORMS: ${{ github.ref == 'refs/heads/main' }}
29+
30+
jobs:
31+
docker-latest:
32+
runs-on: ubuntu-latest
33+
34+
permissions:
35+
contents: read
36+
packages: write
37+
attestations: write
38+
id-token: write
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v3
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
- name: Log in to Docker Hub
48+
uses: docker/login-action@v3
49+
with:
50+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
51+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
52+
- name: Log in to the GitHub Container registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Extract metadata (tags, labels) for Docker
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
tags: |
64+
type=semver,pattern={{version}}
65+
type=ref,event=branch
66+
type=ref,event=pr
67+
type=raw,value=latest,enable={{is_default_branch}}
68+
images: |
69+
${{ env.DOCKER_NAMESPACE }}/matrix-hookshot
70+
ghcr.io/matrix-org/matrix-hookshot
71+
72+
- name: Build and push Docker images
73+
id: push
74+
uses: docker/build-push-action@v6
75+
with:
76+
context: .
77+
# arm64 builds OOM without the git fetch setting. c.f.
78+
# https://github.com/rust-lang/cargo/issues/10583
79+
build-args: |
80+
CARGO_NET_GIT_FETCH_WITH_CLI=true
81+
platforms: ${{ (env.BUILD_FOR_ALL_PLATFORMS == 'true' && env.PLATFORMS_PUSH) || env.PLATFORMS }}
82+
push: true
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}

changelog.d/994.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Push Docker images to ghcr.io, and and build an image on each commit.

0 commit comments

Comments
 (0)