-
-
Notifications
You must be signed in to change notification settings - Fork 10
140 lines (131 loc) · 5.03 KB
/
Copy pathcontainer-build.yaml
File metadata and controls
140 lines (131 loc) · 5.03 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
133
134
135
136
137
138
139
140
name: "Container Build"
on:
workflow_dispatch: # needed for manually running this workflow
schedule:
- cron: "15 3 * * *" # sadly there is no TZ support here
push:
branches:
- "main"
- "develop"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
container:
image: moby/buildkit:latest
options: --privileged
steps:
- name: Ensure GNU tar is available
run: |
if command -v tar >/dev/null 2>&1; then
if tar --version 2>/dev/null | grep -qi "gnu tar"; then
echo "GNU tar already present"; exit 0;
fi
fi
if command -v apt-get >/dev/null 2>&1; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y tar
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache tar
elif command -v yum >/dev/null 2>&1; then
yum install -y tar
else
echo "Unable to install GNU tar: unsupported package manager" >&2
exit 1
fi
command -v tar >/dev/null 2>&1 || { echo "tar still missing" >&2; exit 1; }
- name: Checkout code
uses: actions/checkout@v7
- name: Restore repository API cache
id: repository-api-cache-restore
uses: actions/cache/restore@v6
with:
path: website/data/cache
key: repository-api-cache-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
repository-api-cache-${{ github.ref_name }}-
repository-api-cache-
- name: Ensure cache directory exists
run: mkdir -p website/data/cache
- name: Build container
run: |
VERSION="${GITHUB_SHA::12}"
RUN_KIND="${{ github.event_name }}"
case "$RUN_KIND" in
workflow_dispatch|schedule)
# full run (manual trigger or cron) – build and push the image with ref-specific tag
REPO="$(echo "$GITHUB_REPOSITORY" | tr "[:upper:]" "[:lower:]")"
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
;;
*)
# lightweight fallback (e.g. push event) – skip image push and use reduced wiki dataset
PARAMS="--output type=image,push=false --opt build-arg:WIKI_FILE=website/test/3rd-Party-Modules.md"
;;
esac
# registry credentials
export DOCKER_CONFIG="$(pwd)/container"
echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"$(echo -n ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | base64 -w 0)\"}}}" > $DOCKER_CONFIG/config.json
echo "ASSET_VERSION=$VERSION"
# build
buildctl-daemonless.sh build \
--progress plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=container \
--opt build-arg:GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
--opt build-arg:ASSET_VERSION="$VERSION" \
$PARAMS \
--output type=local,dest=build-output
# The local exporter writes the final image filesystem; our website
# data lives under /usr/share/nginx/website (see container/Dockerfile).
# The pipeline always writes both of these files, so a missing file
# is a real error and should fail the build.
WEBSITE_DATA="build-output/usr/share/nginx/website/data"
rm -rf website/data/cache
mkdir -p website/data/cache
cp -a "$WEBSITE_DATA/cache/." website/data/cache/
cp "$WEBSITE_DATA/skipped_modules.json" website/data/skipped_modules.json
rm -rf build-output
- name: Upload pipeline data for validation
if: always()
uses: actions/upload-artifact@v7
with:
name: website-data
path: website/data/skipped_modules.json
retention-days: 1
if-no-files-found: warn
- name: Save repository API cache
if: always()
uses: actions/cache/save@v6
with:
path: website/data/cache
key: repository-api-cache-${{ github.ref_name }}-${{ github.run_id }}
validate-skipped-modules:
needs: build
runs-on: ubuntu-slim
timeout-minutes: 5
if: always() # Run even if build fails, as long as it completed
steps:
- name: Check out repository code
uses: actions/checkout@v7
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*
- name: Download pipeline data
uses: actions/download-artifact@v8
with:
name: website-data
path: website/data
- name: Validate no modules were skipped
run: node scripts/validate-skipped-modules.ts
- name: Upload skipped modules report (if validation failed)
if: failure()
uses: actions/upload-artifact@v7
with:
name: skipped-modules-report
path: website/data/skipped_modules.json
retention-days: 30