Skip to content

Commit 6d5579c

Browse files
committed
ci: diagnose token expression
1 parent 3186513 commit 6d5579c

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/diag-expr.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Diag Expr
2+
3+
on:
4+
push:
5+
branches: [diag/token-expr]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Compare the fallback expression against the secret alone
15+
env:
16+
TOK_EXPR: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
17+
TOK_DIRECT: ${{ secrets.RELEASE_PLEASE_TOKEN }}
18+
run: |
19+
set -u
20+
echo "expr len=${#TOK_EXPR} prefix=${TOK_EXPR%%_*}_"
21+
echo "direct len=${#TOK_DIRECT} prefix=${TOK_DIRECT%%_*}_"
22+
if [ "$TOK_EXPR" = "$TOK_DIRECT" ]; then echo "SAME token"; else echo "DIFFERENT token"; fi
23+
24+
echo "--- exact release-please payload, via the expression token ---"
25+
curl -sS -o /tmp/a.json -w 'http=%{http_code}\n' \
26+
-X POST -H "Authorization: token $TOK_EXPR" \
27+
-H "Accept: application/vnd.github+json" \
28+
https://api.github.com/repos/${{ github.repository }}/releases \
29+
-d '{"name":"v1.3.0-diag","tag_name":"v1.3.0-diag","body":"diag notes","draft":false,"prerelease":false,"target_commitish":"25403c7"}'
30+
echo "expr result: $(jq -r '.message // "created"' /tmp/a.json)"
31+
ida=$(jq -r '.id // empty' /tmp/a.json)
32+
if [ -n "$ida" ]; then
33+
curl -sS -o /dev/null -w 'cleanup rel=%{http_code}\n' -X DELETE -H "Authorization: token $TOK_EXPR" \
34+
https://api.github.com/repos/${{ github.repository }}/releases/$ida
35+
curl -sS -o /dev/null -w 'cleanup tag=%{http_code}\n' -X DELETE -H "Authorization: token $TOK_EXPR" \
36+
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/v1.3.0-diag
37+
fi

0 commit comments

Comments
 (0)