-
Notifications
You must be signed in to change notification settings - Fork 38
106 lines (91 loc) · 3.87 KB
/
docker-server.yml
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
name: Build & Publish Parsec Server Docker Image
# cspell:words buildx
on:
workflow_dispatch:
pull_request:
paths:
- server/packaging/server/**
- .github/workflows/docker-server.yml
# Only run on pushed tag because we don't want this workflow to run everytime we push something to the main branch.
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
- nightly
permissions:
contents: write
packages: write
# We set `concurrency` to prevent having this workflow being run on code that is not up-to-date on a PR (a user make multiple push in a quick manner).
# But outside of a PR, we want to have only 1 workflow to be run at the same time on a given git ref
concurrency:
group: docker-server-${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
docker-server:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # pin v4.1.2
timeout-minutes: 3
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0
- name: Log in to the Github Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get current version
id: version
run: python misc/releaser.py version --uniq-dev | tee -a $GITHUB_OUTPUT
timeout-minutes: 1
- name: Generate build metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
id: metadata
with:
images:
ghcr.io/scille/parsec-cloud/parsec-server
tags: |
type=semver,pattern={{ version }}
type=semver,pattern={{ major }}.{{ minor }}
type=raw,value=${{ steps.version.outputs.docker }}
type=schedule,enable=${{ github.event_name == 'push' && github.ref_type == 'tag' && github.ref == 'refs/tags/nightly' && 'true' || 'false' }},pattern=nightly
flavor: |
latest=${{ github.event_name == 'push' && github.ref_type == 'tag' }}
- name: Build and export to Docker
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
id: build
with:
context: .
file: server/packaging/server/server.dockerfile
load: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: false
timeout-minutes: 20
- name: Start docker test container
id: test-container
run: |
(
echo -n "id=";
docker run --detach --publish 6777:6777 --rm --name=parsec-server ${{ steps.build.outputs.imageid }} -- run --port=6777 --dev --host=0.0.0.0
) | tee $GITHUB_OUTPUT
timeout-minutes: 1
- name: Test docker image
run: python .github/scripts/test-server.py
timeout-minutes: 1
- name: Stop docker test container
run: docker container stop ${{ steps.test-container.outputs.id }}
timeout-minutes: 1
- name: Image to be published
run: echo "${{ steps.metadata.outputs.tags }}"
- name: Build and publish
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
id: publish
with:
context: .
file: server/packaging/server/server.dockerfile
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: ${{ (github.event_name == 'push' && github.ref_type == 'tag') || github.event_name == 'workflow_dispatch' }}