-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (81 loc) · 2.91 KB
/
build-push.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
name: build-push
run-name: |
build-push:
${{ github.event.inputs.versioned == 'true' && 'versioned , ' || ', ' }}
${{ github.event.inputs.latest == 'true' && 'latest , ' || ', ' }}
${{ github.event.inputs.custom_tag != '' && github.event.inputs.custom_tag || '' }}
on:
workflow_dispatch:
inputs:
versioned:
description: 'Push with versioned tag?'
required: true
type: boolean
default: true
latest:
description: 'Push with "latest" tag?'
required: true
type: boolean
default: true
custom_tag:
description: 'Specify a custom tag to push'
required: false
type: string
default: ""
jobs:
build-test-push:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: sandpaper:testing
# - name: Test
# run: |
# expected=""
# actual=""
# if [ "$expected" = "$actual" ]; then
# echo "Passed - $actual"
# else
# echo "ERROR - Expected: $expected"
# echo " Actual: $actual"
# status=1
# fi
# exit $status
- name: Create tag from sandpaper, varnish and pandoc versions
id: tag
run: |
sandpaper=$(grep "ARG sandpaper_version=" Dockerfile | cut -f2 -d"=")
varnish=$(grep "ARG varnish_version=" Dockerfile | cut -f2 -d"=")
pandoc=$(grep "ARG pandoc_version=" Dockerfile | cut -f2 -d"=")
versions=s${sandpaper}-v${varnish}-p${pandoc}
echo "Versioned tag: ${versions}"
echo "versions=${versions}" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push versioned
if: github.event.inputs.versioned == 'true'
run: |
docker image tag sandpaper:testing ghcr.io/uomresearchit/sandpaper:${{ steps.tag.outputs.versions }}
docker push ghcr.io/uomresearchit/sandpaper:${{ steps.tag.outputs.versions }}
- name: Push latest
if: github.event.inputs.latest == 'true'
run: |
docker image tag sandpaper:testing ghcr.io/uomresearchit/sandpaper:latest
docker push ghcr.io/uomresearchit/sandpaper:latest
- name: Push custom_tag
if: github.event.inputs.custom_tag != ''
run: |
docker image tag sandpaper:testing ghcr.io/uomresearchit/sandpaper:${{ github.event.inputs.custom_tag }}
docker push ghcr.io/uomresearchit/sandpaper:${{ github.event.inputs.custom_tag }}