resolve-args.yaml•1.44 kB
name: ResolveArgs
on:
workflow_call:
inputs:
allowed_comment:
type: string
required: true
outputs:
SHOULD_RUN:
value: ${{ jobs.resolve.outputs.SHOULD_RUN }}
GIT_REF:
value: ${{ jobs.resolve.outputs.GIT_REF }}
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
SHOULD_RUN: ${{ steps.resolve-step.outputs.SHOULD_RUN }}
GIT_REF: ${{ steps.resolve-step.outputs.GIT_REF }}
steps:
# Download the artifact and resolve the commit if initiated by PR snapshot
# Otherwise, use the currently checked-out branch to run the E2E tests against
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- if: github.event_name == 'workflow_run'
uses: ./.github/actions/download-artifact
- id: resolve-step
env:
ALLOWED_COMMENT: ${{ inputs.allowed_comment }}
run: |
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
if [[ "$(head -n 1 /tmp/artifacts/metadata.txt)" == *"$ALLOWED_COMMENT"* ]]; then
echo SHOULD_RUN=true >> "$GITHUB_OUTPUT"
else
echo SHOULD_RUN=false >> "$GITHUB_OUTPUT"
fi
echo GIT_REF="$(tail -n 1 /tmp/artifacts/metadata.txt)" >> "$GITHUB_OUTPUT"
else
echo SHOULD_RUN=true >> "$GITHUB_OUTPUT"
echo GIT_REF="" >> "$GITHUB_OUTPUT"
fi