From 49c2072cbe3c9b8270ac6dff2bc08ebaf7a2749e Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 8 Jul 2025 04:51:37 +0000 Subject: [PATCH] actions: use FORGEJO_* instead of GITHUB_* and test backward compatibility (#758) Refs forgejo/act#171 Refs actions/setup-forgejo#461 Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/758 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- .../.forgejo/workflows/test.yml | 232 ++++++++++-------- .../action-for-context/action.yml | 24 +- 2 files changed, 140 insertions(+), 116 deletions(-) diff --git a/actions/example-context/.forgejo/workflows/test.yml b/actions/example-context/.forgejo/workflows/test.yml index 0f9db31b..1a092cd9 100644 --- a/actions/example-context/.forgejo/workflows/test.yml +++ b/actions/example-context/.forgejo/workflows/test.yml @@ -15,191 +15,213 @@ jobs: test "$CI" = true test "$CI" = "${{ env.CI }}" - - name: GITHUB_ACTION + - name: FORGEJO_ACTION run: | set -x - echo "$GITHUB_ACTION" | grep -E '^[0-9]+$' - test "$GITHUB_ACTION" = "${{ env.GITHUB_ACTION }}" - test "$GITHUB_ACTION" = "${{ github.ACTION }}" - test "$GITHUB_ACTION" = "${{ forge.ACTION }}" + echo "$FORGEJO_ACTION" | grep -E '^[0-9]+$' + test "$FORGEJO_ACTION" = "${{ env.FORGEJO_ACTION }}" + test "$FORGEJO_ACTION" = "${{ github.ACTION }}" + test "$FORGEJO_ACTION" = "${{ forge.ACTION }}" + test "$FORGEJO_ACTION" = "$GITHUB_ACTION" # See also actions/example-local-action/.forgejo/local-action/action.yml - - name: GITHUB_ACTION_PATH + - name: FORGEJO_ACTION_PATH run: | set -x - test -z "$GITHUB_ACTION_PATH" - test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}" - test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}" - test "$GITHUB_ACTION_PATH" = "${{ forge.ACTION_PATH }}" + test -z "$FORGEJO_ACTION_PATH" + test "$FORGEJO_ACTION_PATH" = "${{ env.FORGEJO_ACTION_PATH }}" + test "$FORGEJO_ACTION_PATH" = "${{ github.ACTION_PATH }}" + test "$FORGEJO_ACTION_PATH" = "${{ forge.ACTION_PATH }}" + test "$FORGEJO_ACTION_PATH" = "$GITHUB_ACTION_PATH" - name: when running an action - if: ${{ env.GITHUB_ACTIONS }} + if: ${{ env.FORGEJO_ACTIONS }} uses: SELF@main with: input-one: "otherone" - - name: GITHUB_ACTION_REPOSITORY - run: test -f /srv/example/example-context/GITHUB_ACTION_REPOSITORY + - name: FORGEJO_ACTION_REPOSITORY + run: test -f /srv/example/example-context/FORGEJO_ACTION_REPOSITORY - - name: GITHUB_ACTION_PATH - run: test -f /srv/example/example-context/GITHUB_ACTION_PATH + - name: FORGEJO_ACTION_PATH + run: test -f /srv/example/example-context/FORGEJO_ACTION_PATH - - name: GITHUB_ACTIONS + - name: FORGEJO_ACTIONS run: | set -x - test "$GITHUB_ACTIONS" = true - test "$GITHUB_ACTIONS" = "${{ env.GITHUB_ACTIONS }}" + test "$FORGEJO_ACTIONS" = true + test "$FORGEJO_ACTIONS" = "${{ env.FORGEJO_ACTIONS }}" + test "$FORGEJO_ACTIONS" = "$GITHUB_ACTIONS" - - name: GITHUB_ACTOR + - name: FORGEJO_ACTOR run: | set -x - test "$GITHUB_ACTOR" - test "$GITHUB_ACTOR" = "${{ env.GITHUB_ACTOR }}" - test "$GITHUB_ACTOR" = "${{ github.ACTOR }}" - test "$GITHUB_ACTOR" = "${{ forge.ACTOR }}" + test "$FORGEJO_ACTOR" + test "$FORGEJO_ACTOR" = "${{ env.FORGEJO_ACTOR }}" + test "$FORGEJO_ACTOR" = "${{ github.ACTOR }}" + test "$FORGEJO_ACTOR" = "${{ forge.ACTOR }}" + test "$FORGEJO_ACTOR" = "$GITHUB_ACTOR" - - name: GITHUB_API_URL + - name: FORGEJO_API_URL shell: bash run: | set -x - [[ "$GITHUB_API_URL" =~ /api/v1$ ]] - test "$GITHUB_API_URL" = "${{ env.GITHUB_API_URL }}" - test "$GITHUB_API_URL" = "${{ github.API_URL }}" - test "$GITHUB_API_URL" = "${{ forge.API_URL }}" + [[ "$FORGEJO_API_URL" =~ /api/v1$ ]] + test "$FORGEJO_API_URL" = "${{ env.FORGEJO_API_URL }}" + test "$FORGEJO_API_URL" = "${{ github.API_URL }}" + test "$FORGEJO_API_URL" = "${{ forge.API_URL }}" + test "$FORGEJO_API_URL" = "$GITHUB_API_URL" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: GITHUB_BASE_REF + - name: FORGEJO_BASE_REF run: | set -x - test -z "$GITHUB_BASE_REF" - test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}" - test "$GITHUB_BASE_REF" = "${{ github.BASE_REF }}" - test "$GITHUB_BASE_REF" = "${{ forge.BASE_REF }}" + test -z "$FORGEJO_BASE_REF" + test "$FORGEJO_BASE_REF" = "${{ env.FORGEJO_BASE_REF }}" + test "$FORGEJO_BASE_REF" = "${{ github.BASE_REF }}" + test "$FORGEJO_BASE_REF" = "${{ forge.BASE_REF }}" + test "$FORGEJO_BASE_REF" = "$GITHUB_BASE_REF" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: GITHUB_HEAD_REF + - name: FORGEJO_HEAD_REF run: | set -x - test -z "$GITHUB_HEAD_REF" - test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}" - test "$GITHUB_HEAD_REF" = "${{ github.HEAD_REF }}" - test "$GITHUB_HEAD_REF" = "${{ forge.HEAD_REF }}" + test -z "$FORGEJO_HEAD_REF" + test "$FORGEJO_HEAD_REF" = "${{ env.FORGEJO_HEAD_REF }}" + test "$FORGEJO_HEAD_REF" = "${{ github.HEAD_REF }}" + test "$FORGEJO_HEAD_REF" = "${{ forge.HEAD_REF }}" + test "$FORGEJO_HEAD_REF" = "$GITHUB_HEAD_REF" - - name: GITHUB_ENV + - name: FORGEJO_ENV run: | set -x - test -f "$GITHUB_ENV" - test "$GITHUB_ENV" = "${{ env.GITHUB_ENV }}" + test -f "$FORGEJO_ENV" + test "$FORGEJO_ENV" = "${{ env.FORGEJO_ENV }}" + test "$FORGEJO_ENV" = "$GITHUB_ENV" - - name: GITHUB_EVENT_NAME + - name: FORGEJO_EVENT_NAME run: | set -x - test "$GITHUB_EVENT_NAME" = push - test "$GITHUB_EVENT_NAME" = "${{ env.GITHUB_EVENT_NAME }}" - test "$GITHUB_EVENT_NAME" = "${{ github.EVENT_NAME }}" - test "$GITHUB_EVENT_NAME" = "${{ forge.EVENT_NAME }}" + test "$FORGEJO_EVENT_NAME" = push + test "$FORGEJO_EVENT_NAME" = "${{ env.FORGEJO_EVENT_NAME }}" + test "$FORGEJO_EVENT_NAME" = "${{ github.EVENT_NAME }}" + test "$FORGEJO_EVENT_NAME" = "${{ forge.EVENT_NAME }}" + test "$FORGEJO_EVENT_NAME" = "$GITHUB_EVENT_NAME" - - name: GITHUB_JOB + - name: FORGEJO_JOB run: | set -x - test "$GITHUB_JOB" = test - test "$GITHUB_JOB" = "${{ env.GITHUB_JOB }}" - test "$GITHUB_JOB" = "${{ github.JOB }}" - test "$GITHUB_JOB" = "${{ forge.JOB }}" + test "$FORGEJO_JOB" = test + test "$FORGEJO_JOB" = "${{ env.FORGEJO_JOB }}" + test "$FORGEJO_JOB" = "${{ github.JOB }}" + test "$FORGEJO_JOB" = "${{ forge.JOB }}" + test "$FORGEJO_JOB" = "$GITHUB_JOB" - - name: GITHUB_OUTPUT + - name: FORGEJO_OUTPUT run: | set -x - test -f "$GITHUB_OUTPUT" - test "$GITHUB_OUTPUT" = "${{ env.GITHUB_OUTPUT }}" + test -f "$FORGEJO_OUTPUT" + test "$FORGEJO_OUTPUT" = "${{ env.FORGEJO_OUTPUT }}" + test "$FORGEJO_OUTPUT" = "$GITHUB_OUTPUT" - - name: GITHUB_PATH + - name: FORGEJO_PATH run: | set -x - test -f "$GITHUB_PATH" - test "$GITHUB_PATH" = "${{ env.GITHUB_PATH }}" + test -f "$FORGEJO_PATH" + test "$FORGEJO_PATH" = "${{ env.FORGEJO_PATH }}" + test "$FORGEJO_PATH" = "$GITHUB_PATH" - - name: GITHUB_REF + - name: FORGEJO_REF shell: bash run: | set -x - [[ "$GITHUB_REF" =~ ^refs/ ]] - test "$GITHUB_REF" = "${{ env.GITHUB_REF }}" - test "$GITHUB_REF" = "${{ github.REF }}" - test "$GITHUB_REF" = "${{ forge.REF }}" + [[ "$FORGEJO_REF" =~ ^refs/ ]] + test "$FORGEJO_REF" = "${{ env.FORGEJO_REF }}" + test "$FORGEJO_REF" = "${{ github.REF }}" + test "$FORGEJO_REF" = "${{ forge.REF }}" + test "$FORGEJO_REF" = "$GITHUB_REF" - - name: GITHUB_REF_NAME + - name: FORGEJO_REF_NAME shell: bash run: | set -x - ! [[ "$GITHUB_REF_NAME" =~ ^refs/ ]] - test "$GITHUB_REF_NAME" = "${{ env.GITHUB_REF_NAME }}" - test "$GITHUB_REF_NAME" = "${{ github.REF_NAME }}" - test "$GITHUB_REF_NAME" = "${{ forge.REF_NAME }}" + ! [[ "$FORGEJO_REF_NAME" =~ ^refs/ ]] + test "$FORGEJO_REF_NAME" = "${{ env.FORGEJO_REF_NAME }}" + test "$FORGEJO_REF_NAME" = "${{ github.REF_NAME }}" + test "$FORGEJO_REF_NAME" = "${{ forge.REF_NAME }}" + test "$FORGEJO_REF_NAME" = "$GITHUB_REF_NAME" - - name: GITHUB_REPOSITORY + - name: FORGEJO_REPOSITORY run: | set -x - test "$GITHUB_REPOSITORY" = root/example-context - test "$GITHUB_REPOSITORY" = "${{ env.GITHUB_REPOSITORY }}" - test "$GITHUB_REPOSITORY" = "${{ github.REPOSITORY }}" - test "$GITHUB_REPOSITORY" = "${{ forge.REPOSITORY }}" + test "$FORGEJO_REPOSITORY" = root/example-context + test "$FORGEJO_REPOSITORY" = "${{ env.FORGEJO_REPOSITORY }}" + test "$FORGEJO_REPOSITORY" = "${{ github.REPOSITORY }}" + test "$FORGEJO_REPOSITORY" = "${{ forge.REPOSITORY }}" + test "$FORGEJO_REPOSITORY" = "$GITHUB_REPOSITORY" - - name: GITHUB_REPOSITORY_OWNER + - name: FORGEJO_REPOSITORY_OWNER run: | set -x - test "$GITHUB_REPOSITORY_OWNER" = root - test "$GITHUB_REPOSITORY_OWNER" = "${{ env.GITHUB_REPOSITORY_OWNER }}" - test "$GITHUB_REPOSITORY_OWNER" = "${{ github.REPOSITORY_OWNER }}" - test "$GITHUB_REPOSITORY_OWNER" = "${{ forge.REPOSITORY_OWNER }}" + test "$FORGEJO_REPOSITORY_OWNER" = root + test "$FORGEJO_REPOSITORY_OWNER" = "${{ env.FORGEJO_REPOSITORY_OWNER }}" + test "$FORGEJO_REPOSITORY_OWNER" = "${{ github.REPOSITORY_OWNER }}" + test "$FORGEJO_REPOSITORY_OWNER" = "${{ forge.REPOSITORY_OWNER }}" + test "$FORGEJO_REPOSITORY_OWNER" = "$GITHUB_REPOSITORY_OWNER" - - name: GITHUB_RUN_NUMBER + - name: FORGEJO_RUN_NUMBER run: | set -x - echo "$GITHUB_RUN_NUMBER" | grep -E '^[0-9]+$' - test "$GITHUB_RUN_NUMBER" = "${{ env.GITHUB_RUN_NUMBER }}" - test "$GITHUB_RUN_NUMBER" = "${{ github.RUN_NUMBER }}" - test "$GITHUB_RUN_NUMBER" = "${{ forge.RUN_NUMBER }}" + echo "$FORGEJO_RUN_NUMBER" | grep -E '^[0-9]+$' + test "$FORGEJO_RUN_NUMBER" = "${{ env.FORGEJO_RUN_NUMBER }}" + test "$FORGEJO_RUN_NUMBER" = "${{ github.RUN_NUMBER }}" + test "$FORGEJO_RUN_NUMBER" = "${{ forge.RUN_NUMBER }}" + test "$FORGEJO_RUN_NUMBER" = "$GITHUB_RUN_NUMBER" - - name: GITHUB_SERVER_URL + - name: FORGEJO_SERVER_URL shell: bash run: | set -x - [[ "$GITHUB_SERVER_URL" =~ ^http ]] - test "$GITHUB_SERVER_URL" = "${{ env.GITHUB_SERVER_URL }}" - test "$GITHUB_SERVER_URL" = "${{ github.SERVER_URL }}" - test "$GITHUB_SERVER_URL" = "${{ forge.SERVER_URL }}" + [[ "$FORGEJO_SERVER_URL" =~ ^http ]] + test "$FORGEJO_SERVER_URL" = "${{ env.FORGEJO_SERVER_URL }}" + test "$FORGEJO_SERVER_URL" = "${{ github.SERVER_URL }}" + test "$FORGEJO_SERVER_URL" = "${{ forge.SERVER_URL }}" + test "$FORGEJO_SERVER_URL" = "$GITHUB_SERVER_URL" - - name: GITHUB_SHA + - name: FORGEJO_SHA run: | set -x - test "$GITHUB_SHA" - test "$GITHUB_SHA" = "${{ env.GITHUB_SHA }}" - test "$GITHUB_SHA" = "${{ github.SHA }}" - test "$GITHUB_SHA" = "${{ forge.SHA }}" + test "$FORGEJO_SHA" + test "$FORGEJO_SHA" = "${{ env.FORGEJO_SHA }}" + test "$FORGEJO_SHA" = "${{ github.SHA }}" + test "$FORGEJO_SHA" = "${{ forge.SHA }}" + test "$FORGEJO_SHA" = "$GITHUB_SHA" - - name: GITHUB_STEP_SUMMARY + - name: FORGEJO_STEP_SUMMARY run: | set -x - test -f "$GITHUB_STEP_SUMMARY" - test "$GITHUB_STEP_SUMMARY" = "${{ env.GITHUB_STEP_SUMMARY }}" + test -f "$FORGEJO_STEP_SUMMARY" + test "$FORGEJO_STEP_SUMMARY" = "${{ env.FORGEJO_STEP_SUMMARY }}" + test "$FORGEJO_STEP_SUMMARY" = "$GITHUB_STEP_SUMMARY" # See also actions/example-pull-request/.forgejo/workflows/test.yml - - name: GITHUB_TOKEN + - name: FORGEJO_TOKEN run: | set -x - test "$GITHUB_TOKEN" - test "$GITHUB_TOKEN" = "${{ env.GITHUB_TOKEN }}" - test "$GITHUB_TOKEN" = "${{ github.TOKEN }}" - test "$GITHUB_TOKEN" = "${{ forge.TOKEN }}" + test "$FORGEJO_TOKEN" + test "$FORGEJO_TOKEN" = "${{ env.FORGEJO_TOKEN }}" + test "$FORGEJO_TOKEN" = "${{ github.TOKEN }}" + test "$FORGEJO_TOKEN" = "${{ forge.TOKEN }}" + test "$FORGEJO_TOKEN" = "$GITHUB_TOKEN" - - name: GITHUB_WORKSPACE + - name: FORGEJO_WORKSPACE run: | set -x - test -d "$GITHUB_WORKSPACE" - test "$GITHUB_WORKSPACE" = "${{ env.GITHUB_WORKSPACE }}" - test "$GITHUB_WORKSPACE" = "${{ github.WORKSPACE }}" - test "$GITHUB_WORKSPACE" = "${{ forge.WORKSPACE }}" + test -d "$FORGEJO_WORKSPACE" + test "$FORGEJO_WORKSPACE" = "${{ env.FORGEJO_WORKSPACE }}" + test "$FORGEJO_WORKSPACE" = "${{ github.WORKSPACE }}" + test "$FORGEJO_WORKSPACE" = "${{ forge.WORKSPACE }}" + test "$FORGEJO_WORKSPACE" = "$GITHUB_WORKSPACE" - name: RUNNER_ARCH run: | diff --git a/actions/example-context/action-for-context/action.yml b/actions/example-context/action-for-context/action.yml index c1c33843..e8e81c39 100644 --- a/actions/example-context/action-for-context/action.yml +++ b/actions/example-context/action-for-context/action.yml @@ -6,20 +6,22 @@ inputs: runs: using: "composite" steps: - - name: GITHUB_ACTION_REPOSITORY + - name: FORGEJO_ACTION_REPOSITORY run: | set -x - test "$GITHUB_ACTION_REPOSITORY" = root/action-for-context - test "$GITHUB_ACTION_REPOSITORY" = "${{ env.GITHUB_ACTION_REPOSITORY }}" - test "$GITHUB_ACTION_REPOSITORY" = "${{ github.ACTION_REPOSITORY }}" - test "$GITHUB_ACTION_REPOSITORY" = "${{ forge.ACTION_REPOSITORY }}" - touch /srv/example/example-context/GITHUB_ACTION_REPOSITORY + test "$FORGEJO_ACTION_REPOSITORY" = root/action-for-context + test "$FORGEJO_ACTION_REPOSITORY" = "${{ env.FORGEJO_ACTION_REPOSITORY }}" + test "$FORGEJO_ACTION_REPOSITORY" = "${{ github.ACTION_REPOSITORY }}" + test "$FORGEJO_ACTION_REPOSITORY" = "${{ forge.ACTION_REPOSITORY }}" + test "$FORGEJO_ACTION_REPOSITORY" = "$GITHUB_ACTION_REPOSITORY" + touch /srv/example/example-context/FORGEJO_ACTION_REPOSITORY - - name: GITHUB_ACTION_PATH + - name: FORGEJO_ACTION_PATH shell: bash run: | set -x - [[ "$GITHUB_ACTION_PATH" =~ action-for-context@main$ ]] - test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}" - test "$GITHUB_ACTION_PATH" = "${{ forge.ACTION_PATH }}" - touch /srv/example/example-context/GITHUB_ACTION_PATH + [[ "$FORGEJO_ACTION_PATH" =~ action-for-context@main$ ]] + test "$FORGEJO_ACTION_PATH" = "${{ github.ACTION_PATH }}" + test "$FORGEJO_ACTION_PATH" = "${{ forge.ACTION_PATH }}" + test "$FORGEJO_ACTION_PATH" = "$GITHUB_ACTION_PATH" + touch /srv/example/example-context/FORGEJO_ACTION_PATH