-
Notifications
You must be signed in to change notification settings - Fork 140
101 lines (99 loc) · 3.17 KB
/
docker.yml
File metadata and controls
101 lines (99 loc) · 3.17 KB
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
name: "build docker archive"
permissions: {}
on:
workflow_call:
inputs:
version:
description: 'version to archive'
required: false
default: dev
type: string
latest:
description: 'tag with latest?'
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
version:
description: 'version to archive'
required: true
type: string
latest:
description: 'tag with latest?'
required: false
default: false
type: boolean
jobs:
docker:
name: docker Build
runs-on: ubuntu-latest
env:
docker_repository: ${{ case(github.repository == 'GPSBabel/gpsbabel', 'tsteven4/gpsbabel', 'tsteven4/testing') }}
steps:
- name: Compute tag
id: compute
run: |
if [ "${{ inputs.version }}" == "dev" ]; then
echo "tag=master" >> "$GITHUB_OUTPUT"
else
echo "tag=gpsbabel_$(echo ${{ inputs.version }} | tr . _)" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ steps.compute.outputs.tag }}
fetch-depth: 0
- name: Update archive_images
run: |
git checkout ${{ github.sha }} -- tools/archive_images
- name: Patch
run: |
patch=tools/archive_images/gpsbabel_$(echo ${{ inputs.version }} | tr . _).patch
if [ -e "${patch}" ]; then
echo "Applying patch ${patch}"
git apply -v "${patch}"
fi
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: tsteven4
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and load
uses: docker/build-push-action@v7
with:
context: .
file: ./tools/archive_images/Dockerfile_gpsbabel_${{ inputs.version }}
load: true
tags: "${{ env.docker_repository }}:test_${{ inputs.version }}"
- name: Test
run: |
# tests failed before 1.6.0 (and repository structure was different)
if [[ "${{ inputs.version }}" == "dev" || $(echo -e "${{ inputs.version }}\n1.6.0" | sort -V | head -n1) == "1.6.0" ]]; then
docker run --rm --volume ${{ github.workspace }}:/app "${{ env.docker_repository }}:test_${{ inputs.version }}" \
/bin/bash -c 'PNAME=$(which gpsbabel) ./testo'
fi
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v6
with:
flavor: |
latest=false
images: |
${{ env.docker_repository }}
tags: |
type=raw,value=${{ inputs.version }}
type=raw,value=${{ inputs.version }}_{{date 'YYYYMMDD[T]HHmmss[Z]' tz='UTC'}}
type=raw,value=latest,enable=${{ inputs.latest }}
context: git
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./tools/archive_images/Dockerfile_gpsbabel_${{ inputs.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}