-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.64 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Publish
# Only allow this workflow to run once per workflow and event type/number.
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
# Run this workflow every time a new commit pushed to the master branch in your repository.
on:
push:
# branches:
# - master
tags:
- 'v*'
#
# Only run this workflow after the "Test" workflow has completed successfully.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
#
workflow_run:
workflows:
- Test
types:
- completed
## FIXME: Would this then also trigger for PRs and such? Because it shouldn't!
branches:
- master
# Allow triggering manually.
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job will build and publish the container image to GitHub Container Registry.
publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
## TODO: We need to start using semver tags for the container image,
## as this will ONLY create/update the "latest" tag for versioned releases!
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and Publish
uses: docker/build-push-action@v4
with:
pull: true
push: ${{ github.event_name != 'pull_request' }} # Only push if not a pull request
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# This job will only run if the dependent workflows failed.
# skip:
# name: Skip
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
# timeout-minutes: 5
# steps:
# - name: Skip
# run: echo "Skipping publish because dependent workflows have failed."