-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 1.63 KB
/
container-image.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: Docker Image CI
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TAG: "3.1"
jobs:
main-root:
outputs:
is-main: ${{ steps.is-main-root.outputs.test }}
runs-on: ubuntu-latest
steps:
- name: Echo a message
if: github.ref == 'refs/heads/main' && github.repository == 'commonhaus/pandoc-pdf'
id: is-main-root
run: echo "test=true" >> "$GITHUB_OUTPUT"
build:
needs: main-root
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: |
type=raw,enable=true,priority=200,prefix=,suffix=,value=${{ env.TAG }}
- name: Log in to the Container registry
if: ${{needs.main-root.outputs.is-main}}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6.9.0
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Publish OCI image to GCR
if: ${{needs.main-root.outputs.is-main}}
id: publish-oci
run: |
image="${IMAGE_NAME}:${TAG}"
docker tag "${image}" "ghcr.io/${image}"
docker push "ghcr.io/${image}"