-
Notifications
You must be signed in to change notification settings - Fork 72
131 lines (116 loc) · 3.6 KB
/
publish-packages.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
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
name: publish-packages
run-name: Publish packages
on:
push:
paths:
- .github/workflows/publish-packages.yml
- .github/packages/**
pull_request:
paths:
- .github/workflows/publish-packages.yml
- .github/packages/**
schedule:
# Monday at 5am EST
- cron: "0 10 * * 1"
concurrency:
group: "packages"
cancel-in-progress: true
jobs:
build-linux:
name: Publish package
env:
REGISTRY: ghcr.io
CONTAINERFILE: .github/packages/build-linux/Dockerfile
OUTPUT: ${{github.workspace}}/output
strategy:
matrix:
target: [ "build-linux", "gen-pages", "check-issues" ]
fail-fast: false
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Get image name
env:
REPO_NAME: ${{ github.repository }}
IMAGE_SUFFIX: ${{ matrix.target }}
run: |
result=$(echo "$REPO_NAME/$IMAGE_SUFFIX" | tr '[:upper:]' '[:lower:]')
echo "IMAGE=$result" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build package
id: build
uses: docker/build-push-action@v4
with:
context: .
file: ${{ env.CONTAINERFILE }}
target: ${{ matrix.target }}
load: true
tags: ${{ env.IMAGE }}:test
- name: Try building Melee (GENERATE_MAP=1)
if: startsWith(matrix.target, 'build-')
run: |
output="$OUTPUT/generate_map"
mkdir -p "$output"
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD:/input:ro" \
--volume "$output:/output" \
--env MAKE_FLAGS="GENERATE_MAP=1" \
"$IMAGE:test"
- name: Try checking for code issues
if: matrix.target == 'check-issues'
run: |
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD:/input:ro" \
"$IMAGE:test"
- name: Try generating pages
if: matrix.target == 'gen-pages'
run: |
output="$OUTPUT/gen_pages"
mkdir -p "$output"
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD:/input:ro" \
--volume "$output:/output" \
"$IMAGE:test"
- name: Upload GitHub Pages artifact
if: matrix.target == 'gen-pages'
uses: actions/upload-pages-artifact@v3
with:
path: ${{env.OUTPUT}}/gen_pages
- name: Extract tags and labels
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE }}
tags: |
type=raw,priority=1000,value=latest,enable={{is_default_branch}}
type=schedule,pattern={{date 'YYYYMMDD'}}
type=ref,event=branch
type=ref,event=pr
type=edge
type=sha
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push package
uses: docker/build-push-action@v4
if: github.event_name != 'pull_request'
with:
context: .
file: ${{ env.CONTAINERFILE }}
target: ${{ matrix.target }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}