2021-11-11 22:18:29 -06:00
|
|
|
name: Build container image
|
|
|
|
on:
|
2021-11-16 14:42:14 -06:00
|
|
|
workflow_dispatch:
|
2021-11-11 22:18:29 -06:00
|
|
|
push:
|
|
|
|
branches:
|
2022-03-20 22:46:11 -05:00
|
|
|
- 'main'
|
2021-11-11 22:18:29 -06:00
|
|
|
tags:
|
2022-03-20 22:46:11 -05:00
|
|
|
- '*'
|
2022-02-14 09:08:02 -06:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- .github/workflows/build-image.yml
|
|
|
|
- Dockerfile
|
2022-09-08 02:44:24 -05:00
|
|
|
permissions:
|
|
|
|
contents: read
|
2023-03-14 14:27:43 -05:00
|
|
|
packages: write
|
2022-09-08 02:44:24 -05:00
|
|
|
|
2021-11-11 22:18:29 -06:00
|
|
|
jobs:
|
|
|
|
build-image:
|
|
|
|
runs-on: ubuntu-latest
|
2023-01-29 20:07:19 -06:00
|
|
|
|
|
|
|
concurrency:
|
2023-02-17 23:56:16 -06:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
2023-01-29 20:07:19 -06:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-11-11 22:18:29 -06:00
|
|
|
steps:
|
2022-06-19 00:38:07 -05:00
|
|
|
- uses: actions/checkout@v3
|
2023-01-24 02:48:05 -06:00
|
|
|
- uses: hadolint/hadolint-action@v3.1.0
|
2022-06-20 04:52:12 -05:00
|
|
|
- uses: docker/setup-qemu-action@v2
|
2022-06-21 21:35:39 -05:00
|
|
|
- uses: docker/setup-buildx-action@v2
|
2023-03-14 14:27:43 -05:00
|
|
|
|
|
|
|
- name: Log in to Docker Hub
|
|
|
|
uses: docker/login-action@v2
|
2021-11-11 22:18:29 -06:00
|
|
|
with:
|
2021-11-13 23:11:05 -06:00
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2023-03-14 21:43:49 -05:00
|
|
|
if: github.repository == 'mastodon/mastodon' && github.event_name != 'pull_request'
|
2023-03-14 14:27:43 -05:00
|
|
|
|
|
|
|
- name: Log in to the Github Container registry
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2023-03-14 21:43:49 -05:00
|
|
|
if: github.repository == 'mastodon/mastodon' && github.event_name != 'pull_request'
|
2023-03-14 14:27:43 -05:00
|
|
|
|
2022-06-19 00:39:21 -05:00
|
|
|
- uses: docker/metadata-action@v4
|
2021-11-11 22:18:29 -06:00
|
|
|
id: meta
|
|
|
|
with:
|
2023-03-14 14:27:43 -05:00
|
|
|
images: |
|
|
|
|
tootsuite/mastodon
|
|
|
|
ghcr.io/mastodon/mastodon
|
2021-11-11 22:18:29 -06:00
|
|
|
flavor: |
|
2021-11-13 23:11:05 -06:00
|
|
|
latest=auto
|
2021-11-11 22:18:29 -06:00
|
|
|
tags: |
|
|
|
|
type=edge,branch=main
|
2022-10-09 17:32:40 -05:00
|
|
|
type=pep440,pattern={{raw}}
|
|
|
|
type=pep440,pattern=v{{major}}.{{minor}}
|
2022-02-23 09:44:16 -06:00
|
|
|
type=ref,event=pr
|
2023-03-14 14:27:43 -05:00
|
|
|
|
2023-05-04 06:45:39 -05:00
|
|
|
- name: Generate version suffix
|
|
|
|
id: version_vars
|
|
|
|
if: github.repository == 'mastodon/mastodon' && github.event_name == 'push' && github.ref_name == 'main'
|
|
|
|
run: |
|
|
|
|
echo mastodon_version_suffix=\"+edge-$(git rev-parse --short HEAD)\" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-02-01 05:09:43 -06:00
|
|
|
- uses: docker/build-push-action@v4
|
2021-11-11 22:18:29 -06:00
|
|
|
with:
|
|
|
|
context: .
|
2023-05-04 06:45:39 -05:00
|
|
|
build-args: MASTODON_VERSION_SUFFIX=${{ steps.version_vars.outputs.mastodon_version_suffix }}
|
2022-03-30 07:34:53 -05:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2023-02-01 06:15:42 -06:00
|
|
|
provenance: false
|
2022-11-17 04:01:16 -06:00
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
2023-03-15 10:43:44 -05:00
|
|
|
push: ${{ github.repository == 'mastodon/mastodon' && github.event_name != 'pull_request' }}
|
2021-11-11 22:18:29 -06:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2023-03-14 14:27:43 -05:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2022-11-17 04:01:16 -06:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|