-
Notifications
You must be signed in to change notification settings - Fork 11
52 lines (44 loc) · 1.52 KB
/
publish-on-release.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
# loosley based on https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
#
# a push to "/refs/heads/releases/v1" results in a tag of "releases-v1" per https://github.com/docker/metadata-action#usage
name: Create and publish a Docker image on release
on:
push:
branches: ['release']
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image-to-ghcr:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Login to ghcr.io Container registry
# should this be pinned?
# https://github.com/docker/login-action
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Extract metadata (tags + labels) for Docker
id: meta
# should this be pinned?
# https://github.com/docker/metadata-action
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
# should this be pinned?
# https://github.com/docker/build-push-action
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.output.labels }}