Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: cache-trust
on:
push: { branches: [main] }
pull_request:
on: { pull_request: {} }
permissions:
id-token: write
contents: read
jobs:
build:
oidc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: restore cache
id: c
uses: actions/cache@v4
with:
path: ./artifact.txt
key: build-${{ github.ref_name }}-v1
restore-keys: build-
- name: show + use cached file (privileged base run consumes this)
- name: mint + decode OIDC token (sub = fork identity or BASE identity?)
run: |
echo "event=${{ github.event_name }} ref=${{ github.ref }}"
cat ./artifact.txt 2>/dev/null || echo "no cache hit; creating clean artifact"
echo "clean-build-$(date +%s)" > ./artifact.txt
echo "REQ_URL_present=${ACTIONS_ID_TOKEN_REQUEST_URL:+yes}"
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ]; then
T=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=crosstrust-test" | python3 -c "import sys,json;print(json.load(sys.stdin).get(\"value\",\"NONE\"))")
echo "OIDC_CLAIMS_BEGIN"
python3 -c "import base64,json; p=\"$T\".split(\".\")[1]; print(json.dumps(json.loads(base64.urlsafe_b64decode(p+\"==\"))))" 2>/dev/null || echo "decode-failed token=${T:0:12}"
echo "OIDC_CLAIMS_END"
else
echo "NO id-token:write granted to this (fork PR) run"
fi