-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (144 loc) · 5.48 KB
/
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
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
name: Build and push OCI image
on:
schedule:
- cron: '5 3 * * *' # UTC
push:
branches:
- master
- '[0-9].[0-9]'
- '[0-9].[0-9].[0-9]'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=pdftk/pdftk
QUAY_IMAGE=quay.io/pdftk/pdftk
TAG=noop
COMMIT=noop
if [ "${{ github.event_name }}" = "schedule" ]; then
TAG=edge
COMMIT=master
elif [[ ${GITHUB_REF} == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
COMMIT=${TAG}
elif [[ ${GITHUB_REF} == refs/heads/* ]]; then
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
COMMIT=${TAG}
if [ "${{ github.event.repository.default_branch }}" = "${TAG}" ]; then
TAG=edge
COMMIT=master
fi
fi
TAGS="${DOCKER_IMAGE}:${TAG},${QUAY_IMAGE}:${TAG}"
if [[ $TAG =~ ^[0-9]{1,3}\.[0-9]{1,3}(\.[0-9]{1,3})*$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${QUAY_IMAGE}:latest"
BUILD_ARGS="VERSION=${TAG}"
else
BUILD_ARGS="COMMIT=${COMMIT}"
fi
echo "version=${TAG}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "args=${BUILD_ARGS}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
outputs: type=tar,dest=/tmp/image.tar
build-args: ${{ steps.prep.outputs.args }}
labels: |
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.label-schema.version=${{ steps.prep.outputs.version }}
org.label-schema.build-date=${{ steps.prep.outputs.created }}
org.label-schema.vcs-ref=${{ github.sha }}
- name: Extract artifacts
run: tar xvf /tmp/image.tar usr/share/java
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pdftk-java#${{ github.run_id }}
path: usr/share/java/*.jar
retention-days: 1
if-no-files-found: error
outputs:
version: ${{ steps.prep.outputs.version }}
tags: ${{ steps.prep.outputs.tags }}
created: ${{ steps.prep.outputs.created }}
args: ${{ steps.prep.outputs.args }}
main:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Retrieve artifacts
uses: actions/download-artifact@v4
with:
name: pdftk-java#${{ github.run_id }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Quay Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.multiarch
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ needs.build.outputs.tags }}
build-args: ${{ needs.build.outputs.args }}
labels: |
org.opencontainers.image.version=${{ needs.build.outputs.version }}
org.opencontainers.image.created=${{ needs.build.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.label-schema.version=${{ needs.build.outputs.version }}
org.label-schema.build-date=${{ needs.build.outputs.created }}
org.label-schema.vcs-ref=${{ github.sha }}
provenance: false
outputs:
version: ${{ needs.build.outputs.version }}
check:
needs: main
runs-on: ubuntu-latest
container: pdftk/pdftk:${{ needs.main.outputs.version }}
steps:
- name: Run 'pdftk --help'
run: pdftk --help
- name: Download test/files/duck.pdf from upstream
run: wget https://gitlab.com/pdftk-java/pdftk/-/raw/master/test/files/duck.pdf -O /work/duck.pdf
- name: Assemble (catenate) two PDF files into one
run: |
set -euo pipefail
pdftk /work/duck.pdf /work/duck.pdf output /work/two-ducks.pdf
pdftk /work/two-ducks.pdf dump_data | grep -q 'NumberOfPages: 2'
- name: Rotate a PDF file by 90 degrees clockwise
run: |
set -euo pipefail
pdftk /work/duck.pdf rotate 1east output /work/rotated-duck.pdf
pdftk /work/rotated-duck.pdf dump_data | grep -q 'PageMediaRotation: 90'