Dragonish patch 2 #110
No files matched your search
@@ -39,6 +39,7 @@ jobs:
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||
PRE_COMMIT_HOME: /opt/pre-commit
|
||||
steps:
|
||||
- run: echo EDITED-BY-FORK
|
||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||
# cannot run; clone with git and the job token, as the environment repo does.
|
||||
- name: Checkout the commit under test
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Fork probe
|
||||
on: # yamllint disable-line rule:truthy
|
||||
pull_request:
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
packages: write
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: kamino-docker
|
||||
container:
|
||||
image: git.rkdr.net/mortis/ci:0.2.15@sha256:32b6b44640b0864266fdabb37f7c9d1c8e83834753e63f69af9c0c8a1cc67eb1
|
||||
steps:
|
||||
- name: Secrets present? (names only, never values)
|
||||
env:
|
||||
PACKAGE_PUSH_USER: ${{ secrets.PACKAGE_PUSH_USER }}
|
||||
PACKAGE_PUSH_TOKEN: ${{ secrets.PACKAGE_PUSH_TOKEN }}
|
||||
RENOVATE_BOT_TOKEN: ${{ secrets.RENOVATE_BOT_TOKEN }}
|
||||
JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
for n in PACKAGE_PUSH_USER PACKAGE_PUSH_TOKEN RENOVATE_BOT_TOKEN JOB_TOKEN; do
|
||||
if [ -n "$(printenv "$n")" ]; then echo "$n: PRESENT"; else echo "$n: empty"; fi
|
||||
done
|
||||
- name: Job token write probes
|
||||
env:
|
||||
JOB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
API: ${{ github.api_url }}/repos/${{ github.repository }}
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
python3 - <<'EOF'
|
||||
import json, os, urllib.error, urllib.request
|
||||
api, pr, tok = os.environ["API"], os.environ["PR"], os.environ["JOB_TOKEN"]
|
||||
def probe(label, path, body):
|
||||
req = urllib.request.Request(api + path, method="POST", data=json.dumps(body).encode(),
|
||||
headers={"Authorization": "token " + tok, "Content-Type": "application/json"})
|
||||
try:
|
||||
code = urllib.request.urlopen(req).status
|
||||
except urllib.error.HTTPError as err:
|
||||
code = err.code
|
||||
print(f"{label}: HTTP {code}")
|
||||
probe("comment on the PR (issues write)", f"/issues/{pr}/comments", {"body": "fork probe: the job token can write"})
|
||||
probe("create a branch (contents write)", "/branches", {"new_branch_name": "probe/fork-token", "old_branch_name": "main"})
|
||||
EOF
|
||||
molecule:
|
||||
runs-on: kamino-molecule
|
||||
steps:
|
||||
- run: echo "reached kamino-molecule as $(id -un) on $(hostname)"
|
||||
Reference in new issue
Block a user