Repository navigation
100 lines (88 loc) · 3.55 KB
/
Copy pathdocker-release.yml
File metadata and controls
100 lines (88 loc) · 3.55 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
name: Docker release
on:
# A tag push is the only automatic trigger. `gh release create` pushes the tag and
# publishes the release together, so a `release` trigger would build twice.
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Image tag to publish (e.g. latest or v0.1.0)'
required: true
default: 'latest'
# Called by nightly-minor-deps-release.yml and refresh-external.yml: a tag pushed with
# GITHUB_TOKEN doesn't fire the tag trigger above.
workflow_call:
inputs:
ref:
description: 'Release tag to check out and publish (e.g. v0.1.1)'
required: true
type: string
concurrency:
group: docker-release-${{ inputs.ref || github.ref }}
cancel-in-progress: false
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref || github.ref }}
# Image names must be lower case (RummerLab/data-stats -> rummerlab/data-stats).
- name: Image name
run: echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# In a workflow_call run github.* describes the caller (schedule on main),
# so the semver tags read the version from inputs.ref instead.
tags: |
type=semver,pattern={{version}},value=${{ inputs.ref }}
type=semver,pattern={{major}}.{{minor}},value=${{ inputs.ref }}
type=semver,pattern={{major}},value=${{ inputs.ref }}
type=raw,value=latest,enable=${{ inputs.ref != '' || startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
labels: |
org.opencontainers.image.title=Physioshark Data
org.opencontainers.image.description=Physioshark shark-nursery data explorer (code only; spreadsheets are mounted at runtime)
org.opencontainers.image.url=http://data.physioshark.org
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Summary
run: |
echo "### Published images" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "${{ steps.meta.outputs.tags }}" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "Upgrade the server with:" >> "$GITHUB_STEP_SUMMARY"
echo '```bash' >> "$GITHUB_STEP_SUMMARY"
echo "docker compose -f docker-compose.ghcr.yml pull && docker compose -f docker-compose.ghcr.yml up -d" >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
echo "The derived database rebuilds itself on start from the mounted spreadsheets." >> "$GITHUB_STEP_SUMMARY"