From ee4a08f2b51fd4eae60b20731bc12a25b0b2c26e Mon Sep 17 00:00:00 2001 From: username Date: Wed, 8 Nov 2023 15:56:08 +0100 Subject: [PATCH] actions/example-pull-request: move is-forked to its own step --- .../.forgejo/workflows/test.yml | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/actions/example-pull-request/.forgejo/workflows/test.yml b/actions/example-pull-request/.forgejo/workflows/test.yml index a05f961..91a906d 100644 --- a/actions/example-pull-request/.forgejo/workflows/test.yml +++ b/actions/example-pull-request/.forgejo/workflows/test.yml @@ -24,15 +24,19 @@ jobs: forgejo-curl.sh --token "$GITHUB_TOKEN" login $GITHUB_SERVER_URL forgejo-curl.sh api_json $GITHUB_SERVER_URL/api/v1/user + - 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 + echo value=false >> $GITHUB_OUTPUT + else + echo value=true >> $GITHUB_OUTPUT + fi + - name: secrets shell: bash run: | set -x - if test ${{ github.event.pull_request.base.repo.full_name }} = ${{ github.event.pull_request.head.repo.full_name }} ; then - forked=false - else - forked=true - fi case $GITHUB_EVENT_NAME in pull_request_target) # @@ -41,7 +45,7 @@ jobs: test "${{ secrets.SECRET }}" ;; pull_request) - if $forked ; then + if ${{ steps.forked.outputs.value }} ; then # # PRs from forked repositories: no secrets # @@ -63,16 +67,11 @@ jobs: shell: bash run: | set -x - if test ${{ github.event.pull_request.base.repo.full_name }} = ${{ github.event.pull_request.head.repo.full_name }} ; then - forked=false - else - forked=true - fi function assert_fail_if_forked() { if "$@" ; then - ! $forked + ! ${{ steps.forked.outputs.value }} else - $forked + ${{ steps.forked.outputs.value }} fi } # @@ -118,6 +117,6 @@ jobs: run: | d=/srv/example-pull-request/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME/${{ github.event.action }} mkdir -p $d - cat > $d/event < $d/event <<'EOF' ${{ toJSON(github.event) }} EOF