Skip to content

Commit 06f8159

Browse files
committed
publish cache
1 parent 23ad18f commit 06f8159

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/build-on-change.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,62 @@ jobs:
115115
rebuild: true
116116
logs: true
117117
secrets: inherit
118+
119+
update-cache:
120+
needs: [detect-changes, build]
121+
if: always() && needs.detect-changes.outputs.has_changes == 'true'
122+
runs-on: ubuntu-latest
123+
steps:
124+
- name: Download sbuild-cache
125+
run: |
126+
curl -fsSL "https://github.com/pkgforge/sbuilder/releases/download/latest/sbuild-cache-x86_64-linux" \
127+
-o /usr/local/bin/sbuild-cache || exit 0
128+
chmod +x /usr/local/bin/sbuild-cache
129+
130+
- name: Download existing cache
131+
continue-on-error: true
132+
env:
133+
GH_TOKEN: ${{ github.token }}
134+
run: |
135+
gh release download cache-latest -p build_cache.sdb -D /tmp/ --repo "${{ github.repository }}" || \
136+
sbuild-cache --cache /tmp/build_cache.sdb init
137+
138+
- name: Update cache with build results
139+
run: |
140+
RECIPES='${{ needs.detect-changes.outputs.changed_recipes }}'
141+
142+
echo "$RECIPES" | jq -c '.[]' | while read -r recipe; do
143+
path=$(echo "$recipe" | jq -r '.path')
144+
145+
# Extract package name from path (e.g., binaries/hello/static.yaml -> hello)
146+
pkg_name=$(basename "$(dirname "$path")")
147+
148+
# TODO: Get actual build status from matrix job results
149+
# For now, mark as success if we got here
150+
status="success"
151+
152+
sbuild-cache --cache /tmp/build_cache.sdb update \
153+
--package "$pkg_name" \
154+
--version "latest" \
155+
--status "$status" || true
156+
done
157+
158+
- name: Generate build summary
159+
run: |
160+
sbuild-cache --cache /tmp/build_cache.sdb gh-summary \
161+
--title "Build Results" \
162+
--host x86_64-Linux || true
163+
164+
- name: Upload updated cache
165+
env:
166+
GH_TOKEN: ${{ github.token }}
167+
run: |
168+
if [ -f "/tmp/build_cache.sdb" ]; then
169+
gh release upload cache-latest /tmp/build_cache.sdb --clobber --repo "${{ github.repository }}" || {
170+
gh release create cache-latest \
171+
--title "Build Cache" \
172+
--notes "Build cache for CI" \
173+
--repo "${{ github.repository }}" \
174+
/tmp/build_cache.sdb
175+
}
176+
fi

0 commit comments

Comments
 (0)