diff --git a/.github/workflows/docker-hub-latest.yml b/.github/workflows/docker-hub-latest.yml deleted file mode 100644 index 99fdb119..00000000 --- a/.github/workflows/docker-hub-latest.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Based on https://github.com/matrix-org/dendrite/blob/master/.github/workflows/docker-hub.yml - -name: "Docker Hub - Latest" - -on: - push: - paths-ignore: - - changelog.d/**' - pull_request: - branches: [ main ] - paths-ignore: - - changelog.d/**' - 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 - PUSH: ${{ github.ref == 'refs/heads/main' }} - -jobs: - docker-latest: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Log in to Docker Hub - if: github.ref == 'refs/heads/main' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Build image - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: ${{ (env.PUSH == 'true' && env.PLATFORMS_PUSH) || env.PLATFORMS }} - push: ${{ env.PUSH }} - tags: | - ${{ env.DOCKER_NAMESPACE }}/matrix-hookshot:latest - - # 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 diff --git a/.github/workflows/docker-hub-release.yml b/.github/workflows/docker-hub-release.yml deleted file mode 100644 index acf58f1d..00000000 --- a/.github/workflows/docker-hub-release.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Based on https://github.com/matrix-org/dendrite/blob/master/.github/workflows/docker-hub.yml - -name: "Docker Hub - Release" - -on: - release: - types: [published] - -env: - DOCKER_NAMESPACE: halfshot - PLATFORMS: linux/amd64,linux/arm64 - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - docker-release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Get release tag - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Build image - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: ${{ env.PLATFORMS }} - push: true - tags: | - ${{ env.DOCKER_NAMESPACE }}/matrix-hookshot:${{ env.RELEASE_VERSION }} - - # 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 \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..7de62023 --- /dev/null +++ b/.github/workflows/docker.yml @@ -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 }} diff --git a/changelog.d/994.misc b/changelog.d/994.misc new file mode 100644 index 00000000..8133a9ba --- /dev/null +++ b/changelog.d/994.misc @@ -0,0 +1 @@ +Push Docker images to ghcr.io, and and build an image on each commit.