-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (62 loc) · 2.6 KB
/
Copy pathcontainer.yml
File metadata and controls
66 lines (62 loc) · 2.6 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
name: Container publication
on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: rusttorrent-container-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
# Privileged publication capacity is selected only for this repository and
# this workflow deliberately has no pull_request trigger.
runs-on: [self-hosted, node-b, linux, x64, publish, docker]
env:
IMAGE: ghcr.io/thedancingdeveloper-org/rusttorrent
steps:
- uses: actions/checkout@v7
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Define immutable and compatibility tags
id: tags
shell: bash
run: |
if [[ "$GITHUB_REF_TYPE" == tag ]]; then
case "$GITHUB_REF_NAME" in v[0-9]*) ;; *) exit 1 ;; esac
printf 'tags=%s\n' "$IMAGE:$GITHUB_REF_NAME,$IMAGE:latest,$IMAGE:beta,$IMAGE:sha-$GITHUB_SHA" >> "$GITHUB_OUTPUT"
else
test "$GITHUB_REF_NAME" = main
printf 'tags=%s\n' "$IMAGE:dev,$IMAGE:sha-$GITHUB_SHA" >> "$GITHUB_OUTPUT"
fi
- name: Build and publish the destination image once
uses: docker/build-push-action@v7
with:
context: .
file: Dockerfile
platforms: ${{ github.ref_type == 'tag' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: true
provenance: false
tags: ${{ steps.tags.outputs.tags }}
cache-from: ''
cache-to: ''
# GitHub does not expose a supported REST mutation for package
# visibility. The package is made public once during repository
# bootstrap; this anonymous pull is the fail-closed enforcement.
- name: Verify the anonymous destination manifest
run: |
if [[ "$GITHUB_REF_TYPE" == tag ]]; then tag="$GITHUB_REF_NAME"; else tag=dev; fi
token=$(curl -fsS 'https://ghcr.io/token?service=ghcr.io&scope=repository:thedancingdeveloper-org/rusttorrent:pull' | jq -r .token)
test -n "$token"
curl -fsS -H "Authorization: Bearer $token" \
-H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \
"https://ghcr.io/v2/thedancingdeveloper-org/rusttorrent/manifests/$tag" > manifest.json
jq -e '.schemaVersion == 2' manifest.json >/dev/null