44 workflow_dispatch :
55 inputs :
66 sqlite_ref :
7- description : ' SQLite reference (tag, branch, or commit, or "latest") '
7+ description : ' Full commit SHA from SQLite repository '
88 required : true
9- default : ' master'
109
11- permissions :
12- contents : write
13- pull-requests : write
10+ permissions : {}
1411
1512jobs :
1613 build :
1714 runs-on : ubuntu-latest
15+ permissions :
16+ contents : write
17+ pull-requests : write
1818 steps :
1919 - name : Checkout repository
2020 uses : actions/checkout@v6
@@ -25,23 +25,15 @@ jobs:
2525 id : resolve-ref
2626 run : |
2727 SQLITE_REF="${{ github.event.inputs.sqlite_ref }}"
28- if [ "$SQLITE_REF" = "latest" ]; then
29- echo "Fetching latest tag..."
30- LATEST_TAG=$(git ls-remote --tags --sort="v:refname" https://github.com/sqlite/sqlite.git "refs/tags/version-*" | tail -n 1 | cut -f 2 | sed 's/refs\/tags\///')
31- echo "Latest tag found: $LATEST_TAG"
32- SQLITE_REF="$LATEST_TAG"
28+ if ! [[ "$SQLITE_REF" =~ ^[0-9a-fA-F]{40}$ ]]; then
29+ echo "Expected a full 40-character commit SHA, got: '$SQLITE_REF'"
30+ exit 1
3331 fi
3432
35- # Get the full commit SHA
3633 SQLITE_SHA=$(git ls-remote https://github.com/sqlite/sqlite.git "$SQLITE_REF" | head -n 1 | cut -f 1)
37- if [ -z "$SQLITE_SHA" ]; then
38- # If not found, maybe it's a tag that needs refs/tags/ prefix or it's already a SHA
39- SQLITE_SHA=$(git ls-remote https://github.com/sqlite/sqlite.git "refs/tags/$SQLITE_REF" | head -n 1 | cut -f 1)
40- fi
41-
42- if [ -z "$SQLITE_SHA" ]; then
43- # Fallback: assume it's a SHA if ls-remote didn't find it as a ref
44- SQLITE_SHA="$SQLITE_REF"
34+ if [ -z "$SQLITE_SHA" ] || [ "$SQLITE_SHA" != "$SQLITE_REF" ]; then
35+ echo "Commit SHA '$SQLITE_REF' was not found in https://github.com/sqlite/sqlite.git"
36+ exit 1
4537 fi
4638
4739 echo "sqlite_ref=$SQLITE_REF" >> $GITHUB_OUTPUT
7062 context : .
7163 load : true
7264 tags : sqlite-wasm-builder:env
73- cache-from : type=gha
74- cache-to : type=gha,mode=max
7565
7666 - name : Run build
7767 if : steps.check-branch.outputs.skip != 'true'
0 commit comments