Repository navigation
91 lines (83 loc) · 2.89 KB
/
Copy pathdocker-image.yml
File metadata and controls
91 lines (83 loc) · 2.89 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
# Builds one product's Docker images and stores them in GitHub's container
# registry (ghcr.io) when someone presses "Run workflow" on the Actions tab.
#
# For getting an image onto a machine before a release exists. A release
# builds, signs and publishes every package for every product; this builds two
# images for one product and nothing else. The images take the repository's
# visibility, private here, so pulling one needs a GitHub token that can read
# packages.
name: Build a Docker image
on:
workflow_dispatch:
inputs:
product:
description: Which product (ascend is Offset Irtiqa)
type: choice
options: [align]
default: ascend
version:
description: Version to stamp on it, x.y.z
default: "0.1.0"
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io/offsetsecurity
PRODUCT: ${{ inputs.product }}
VERSION: ${{ inputs.version }}
jobs:
image:
name: offset-${{ inputs.product }}
runs-on: ubuntu-latest
steps:
# Read from the environment, never pasted into the script, so nothing
# typed into the form can run as a command.
- name: Check the version
run: |
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Version must be x.y.z, not $VERSION"; exit 1; }
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Application image
uses: docker/build-push-action@v6
with:
context: .
file: deploy/docker/Dockerfile
target: runtime
build-args: |
PRODUCT=${{ env.PRODUCT }}
APP_VERSION=${{ env.VERSION }}
tags: |
${{ env.REGISTRY }}/offset-${{ env.PRODUCT }}:${{ env.VERSION }}
${{ env.REGISTRY }}/offset-${{ env.PRODUCT }}:latest
push: true
provenance: false
- name: Updater image
uses: docker/build-push-action@v6
with:
context: .
file: deploy/docker/Dockerfile
target: updater
build-args: |
PRODUCT=${{ env.PRODUCT }}
APP_VERSION=${{ env.VERSION }}
tags: |
${{ env.REGISTRY }}/offset-${{ env.PRODUCT }}-updater:${{ env.VERSION }}
${{ env.REGISTRY }}/offset-${{ env.PRODUCT }}-updater:latest
push: true
provenance: false
- name: How to use it
run: |
{
echo "### offset-$PRODUCT $VERSION is stored on GitHub"
echo
echo "On the machine that will run it:"
echo '```'
echo "docker login ghcr.io -u <your GitHub username>"
echo "docker pull $REGISTRY/offset-$PRODUCT:$VERSION"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"