-
Notifications
You must be signed in to change notification settings - Fork 3
117 lines (102 loc) · 3.21 KB
/
docker-publish.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: build and publish
on:
release:
types: [published]
push:
branches: main
pull_request:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Set up QEMU for cross-platform builds below
- name: Set up QEMU
if: github.event_name == 'release'
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Setup Docker buildx
if: github.event_name == 'release'
uses: docker/setup-buildx-action@v2
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
if: github.event_name == 'release'
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build just the amd64 container to validate the build
# https://github.com/docker/build-push-action
# Upload it as "test" so we can use it to render samples
- name: Build Docker image
if: github.event_name != 'release'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: true
tags: ghcr.io/trustedcomputinggroup/pandoc_test
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and publish Docker image
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
# Push only if releasiing
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
render-samples:
if: github.event_name != 'release'
needs: build-container
runs-on: ubuntu-latest
container:
image: ghcr.io/trustedcomputinggroup/pandoc_test
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run the action on sample1
uses: trustedcomputinggroup/markdown@latest
with:
input-md: sample1.md
output-pdf: sample1.pdf
output-tex: sample1.tex
- name: Run the action on sample2
uses: trustedcomputinggroup/markdown@latest
with:
input-md: sample2.md
output-pdf: sample2.pdf
output-tex: sample2.tex
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: samples
path: |
sample*.pdf
sample*.tex