-
Notifications
You must be signed in to change notification settings - Fork 3
156 lines (140 loc) · 4.51 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: build and publish
on:
# Populate the cache on pushes to main, because if you push to cache on builds for tags,
# the cache can't be read by builds for other tags:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
push:
branches:
- main
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# 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 }}
# Set up QEMU for cross-platform builds below
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and publish Docker image
uses: docker/build-push-action@v5
with:
# Cache layers from the container repo.
# Update the cache only on pushes to main.
# This minimizes the amount of times we have to rebuild pandoc.
cache-from: type=gha
cache-to: ${{ github.event_name == 'push' && 'type=gha' || '' }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# (In case of push only)
# Use the container we just built to build the guide and upload it to the actions artifacts.
render-samples-push:
needs: build-container
runs-on: ubuntu-latest
container:
image: ghcr.io/trustedcomputinggroup/pandoc:main
permissions:
contents: write
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
- name: Run the action on guide
uses: trustedcomputinggroup/markdown@latest
with:
input-md: guide.tcg
output-pdf: guide.pdf
output-tex: guide.tex
output-docx: guide.docx
- name: Upload PDF
uses: actions/upload-artifact@master
with:
name: PDF
path: guide.pdf
# (In case of release only)
# Use the container we just built to build the guide and attach it to the release
render-samples-release:
needs: build-container
runs-on: ubuntu-latest
container:
image: ghcr.io/trustedcomputinggroup/pandoc:latest
permissions:
contents: write
if: ${{ github.event_name == 'release' }}
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
- name: Cache LaTeX files
uses: actions/cache@v3
env:
cache-name: cache-latex-files
with:
path: |
*.aux
*.fdb_latexmk
*.lof
*.lot
*.toc
key: latex-${{ github.run_id }}
restore-keys: latex
- name: Render for release
uses: trustedcomputinggroup/markdown@latest
with:
input-md: guide.tcg
extra-build-options: "--gitstatus --plain_quotes"
output-pdf: guide.pdf
output-docx: guide.docx
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: guide.pdf
tag: ${{ github.ref }}
overwrite: true
body: "Guide (PDF)"
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: guide.docx
tag: ${{ github.ref }}
overwrite: true
body: "Guide (Word)"