Repository navigation
132 lines (115 loc) · 4.26 KB
/
Copy pathdocker-server-image.yml
File metadata and controls
132 lines (115 loc) · 4.26 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Server image build and push
on:
workflow_dispatch:
schedule:
# Every Friday at 1:00 p.m. UTC
- cron: '0 13 * * 5'
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
REGISTRY_IMAGE: tiltedphoques/st-reborn-server
jobs:
build:
if: ${{ github.repository_owner == 'tiltedphoques' || github.event_name != 'schedule' }} # Disable cron runs in forks
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
outputs:
version: ${{ steps.version.outputs.version }}
semver: ${{ steps.version.outputs.semver }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
arch: amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
arch: arm64
steps:
- uses: actions/checkout@v7
with:
# We need full history in order to create a version string (BuildInfo.h)
fetch-depth: 0
- name: Checkout submodules
run: |
git submodule sync --recursive
git submodule update --init --force --recursive --depth=1
- name: Store version in output
id: version
run: |
VERSION=$(git describe --tags)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "semver=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
GITHUB_ACTIONS=true
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
labels: |
org.opencontainers.image.title=Skyrim Together Server
org.opencontainers.image.description=Dedicated server for the Skyrim Together multiplayer mod
org.opencontainers.image.url=https://skyrim-together.com
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.version.outputs.version }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
echo "${digest#sha256:}" > "/tmp/digests/${{ matrix.arch }}"
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digests-${{ matrix.runner }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# Combine images into multi-arch manifest (x86-64 and arm) and push
merge-and-push:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule,pattern=weekly-latest
type=semver,pattern={{version}}
type=raw,value=${{ needs.build.outputs.semver }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Create manifest list and push
run: |
docker buildx imagetools create \
${{ steps.meta.outputs.tags && format('-t {0}', join(fromJSON(steps.meta.outputs.json).tags, ' -t ')) }} \
"${REGISTRY_IMAGE}@sha256:$(cat /tmp/digests/amd64)" \
"${REGISTRY_IMAGE}@sha256:$(cat /tmp/digests/arm64)"