Skip to content

Commit

Permalink
feat: allow overriding github context inputs (#52)
Browse files Browse the repository at this point in the history
This is necessary because a check workflow executing in `gh-org/.trunk`
but targeting `gh-org/gh-repo` will have
`GITHUB_REPOSITORY=gh-org/.trunk`; our workflow needs to replace that
when trunk-action is invoked.
  • Loading branch information
sxlijin committed Mar 21, 2023
1 parent 36aecfe commit 4f077db
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,17 @@ runs:
# Run 'trunk check' on pull request
${GITHUB_ACTION_PATH}/pull_request.sh
env:
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FORK: ${{ github.event.pull_request.head.repo.fork }}
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_EVENT_PULL_REQUEST_BASE_SHA:
${{ env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA || github.event.pull_request.base.sha }}
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FORK:
${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FORK ||
github.event.pull_request.head.repo.fork }}
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA:
${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA || github.event.pull_request.head.sha }}
GITHUB_EVENT_PULL_REQUEST_NUMBER:
${{ env.GITHUB_EVENT_PULL_REQUEST_NUMBER || github.event.pull_request.number }}
GITHUB_REF_NAME: ${{ env.GITHUB_REF_NAME || github.ref_name }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY || github.repository }}
GITHUB_TOKEN: ${{ github.token }}
INPUT_ARGUMENTS: ${{ inputs.arguments }}
INPUT_LABEL: ${{ inputs.label }}
Expand All @@ -172,10 +177,10 @@ runs:
# Run 'trunk check' on push
${GITHUB_ACTION_PATH}/push.sh
env:
GITHUB_EVENT_AFTER: ${{ github.event.after }}
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_EVENT_AFTER: ${{ env.GITHUB_EVENT_AFTER || github.event.after }}
GITHUB_EVENT_BEFORE: ${{ env.GITHUB_EVENT_BEFORE || github.event.before }}
GITHUB_REF_NAME: ${{ env.GITHUB_REF_NAME || github.ref_name }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY || github.repository }}
GITHUB_TOKEN: ${{ github.token }}
INPUT_ARGUMENTS: ${{ inputs.arguments }}
INPUT_LABEL: ${{ inputs.label }}
Expand All @@ -187,9 +192,9 @@ runs:
# Run 'trunk check' on all
${GITHUB_ACTION_PATH}/all.sh
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF_NAME: ${{ env.GITHUB_REF_NAME || github.ref_name }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY || github.repository }}
GITHUB_SHA: ${{ env.GITHUB_SHA || github.sha }}
GITHUB_TOKEN: ${{ github.token }}
INPUT_ARGUMENTS: ${{ inputs.arguments }}
INPUT_LABEL: ${{ inputs.label }}
Expand All @@ -203,8 +208,8 @@ runs:
# Run 'trunk check' on Trunk Merge
${GITHUB_ACTION_PATH}/trunk_merge.sh
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REPOSITORY: ${{ env.GITHUB_REPOSITORY || github.repository }}
GITHUB_SHA: ${{ env.GITHUB_SHA || github.sha }}
GITHUB_TOKEN: ${{ github.token }}
INPUT_ARGUMENTS: ${{ inputs.arguments }}
INPUT_LABEL: ${{ inputs.label }}
Expand Down

0 comments on commit 4f077db

Please sign in to comment.