chore: add assertions for the forge context and use it instead of github where relevant (#748)

Refs forgejo/act#37

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/748
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-07-06 12:15:38 +00:00 committed by earl-warren
parent 07b9318ff7
commit cd1a0f5076
No known key found for this signature in database
GPG key ID: F128CBE6AB3A7201
5 changed files with 27 additions and 8 deletions

View file

@ -18,7 +18,7 @@ jobs:
run: |
set -x
test $GITHUB_TOKEN = ${{ env.GITHUB_TOKEN }}
test $GITHUB_TOKEN = ${{ github.token }}
test $GITHUB_TOKEN = ${{ forge.token }}
export DEBIAN_FRONTEND=noninteractive ; apt-get -qq update ; apt-get install -y -qq curl git >& /dev/null
curl -sS -o /usr/local/bin/forgejo-curl.sh https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh && chmod +x /usr/local/bin/forgejo-curl.sh
forgejo-curl.sh --token "$GITHUB_TOKEN" login $GITHUB_SERVER_URL
@ -27,7 +27,7 @@ jobs:
- name: determine if the PR is from a fork
id: forked
run: |
if test ${{ github.event.pull_request.base.repo.full_name }} = ${{ github.event.pull_request.head.repo.full_name }} ; then
if test ${{ forge.event.pull_request.base.repo.full_name }} = ${{ forge.event.pull_request.head.repo.full_name }} ; then
echo value=false >> $GITHUB_OUTPUT
else
echo value=true >> $GITHUB_OUTPUT
@ -95,7 +95,7 @@ jobs:
#
# create an issue
#
base_repo=${{ github.event.pull_request.base.repo.full_name }}
base_repo=${{ forge.event.pull_request.base.repo.full_name }}
forgejo-curl.sh api_json --data-raw '{"title":"ISSUE"}' $GITHUB_SERVER_URL/api/v1/repos/$base_repo/issues
url=$(echo $GITHUB_SERVER_URL | sed -e "s|://|://$GITHUB_TOKEN@|")
git clone $url/$base_repo base
@ -133,7 +133,7 @@ jobs:
- name: save event
run: |
d=/srv/example/pull-request/contexts/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME
d=/srv/example/pull-request/contexts/${{ forge.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME
mkdir -p $d
cat > $d/github <<'EOF'
${{ toJSON(github) }}