-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (57 loc) · 1.8 KB
/
publish_to_ghcr.yml
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
name: Publish docker images
on:
workflow_call:
inputs:
docker_context:
required: true
type: string
push_to_ghcr:
required: true
type: boolean
ghcr_repo:
required: false
default: false
type: string
image_tag:
required: false
default: ""
type: string
permissions:
contents: read
packages: write
jobs:
build-and-push:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # 2.4.0
- name: Set up QEMU
uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # v1.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # v1.6.0
- name: Login to GitHub Container Registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # v1.10.0
if: ${{ inputs.push_to_ghcr }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Construct tags string
id: tags
run: |
TAGS=""
if [ "${{ inputs.push_to_ghcr }}" == "true" ]; then
TAGS="${TAGS}${{ inputs.ghcr_repo }}:latest,"
if [ "${{ inputs.image_tag }}" != "" ]; then
TAGS="${TAGS}${{ inputs.ghcr_repo }}:${{ inputs.image_tag }},"
fi
fi
echo "::set-output name=tags::$TAGS"
- name: Build and push
id: docker_build
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229 # v2.7.0
with:
context: ${{ inputs.docker_context }}
push: true
tags: ${{ steps.tags.outputs.tags }}