-
-
Notifications
You must be signed in to change notification settings - Fork 10
142 lines (133 loc) · 4.96 KB
/
container-build.yaml
File metadata and controls
142 lines (133 loc) · 4.96 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
141
142
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@v6
- name: Restore repository API cache
id: repository-api-cache-restore
uses: actions/cache/restore@v5
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: |
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
# build
buildctl-daemonless.sh build \
--progress plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=container \
--opt build-arg:GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
$PARAMS \
--output type=local,dest=build-output
if [ -d build-output/data/cache ]; then
rm -rf website/data/cache
mkdir -p website/data/cache
cp -a build-output/data/cache/. website/data/cache/
fi
# Extract skipped_modules.json for validation
if [ -f build-output/data/skipped_modules.json ]; then
mkdir -p website/data
cp build-output/data/skipped_modules.json website/data/skipped_modules.json
else
# Create empty skipped_modules.json if pipeline didn't create it
mkdir -p website/data
echo '[]' > website/data/skipped_modules.json
fi
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@v5
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@v5
- 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.js
- 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