-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 2.71 KB
/
Copy pathbackend-docker.yml
File metadata and controls
88 lines (77 loc) · 2.71 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
name: Publish Backend Docker Image
on:
push:
branches:
- master
paths:
- ".github/workflows/backend-docker.yml"
- "nmstats.Dockerfile"
- "src/**"
- "build/**"
workflow_dispatch:
jobs:
build-and-publish-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- name: Compute deploy tag
id: deploy_tag
run: echo "tag=sha-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v4
- name: Login to Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/butr/nmstats
tags: |
type=raw,value=${{ steps.deploy_tag.outputs.tag }}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v7
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./
file: ./nmstats.Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.deploy_tag.outputs.tag }}
# GitHub-managed cache (type=gha): GitHub garbage-collects it (7-day eviction + per-repo size cap),
# unlike type=local which grew unbounded in /tmp and was kept alive by the actions/cache restore-keys.
# mode=max also caches intermediate (restore/publish) layers, not just the final image.
cache-from: type=gha,scope=nmstats
cache-to: type=gha,scope=nmstats,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Generate dispatch token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.DISPATCH_APP_ID }}
private-key: ${{ secrets.DISPATCH_APP_KEY }}
- name: Trigger 'deploy-docker-image'
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ steps.app-token.outputs.token }}
repository: BUTR/BUTR.NexusModsStats
event-type: deploy-docker-image
client-payload: '{"image_tag": "${{ steps.deploy_tag.outputs.tag }}"}'