New wacky solution to try and determine if this is a PR comment befor… #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test context throws | |
on: | |
workflow_dispatch: | |
# Allow profiling to be triggered by comments on pull requests | |
# Trigger is /run profiling | |
issue_comment: | |
types: | |
- created | |
# Profile the model every Saturday at 00:00, | |
# on the HEAD of master | |
push: | |
branches: | |
- "main" | |
concurrency: | |
group: fetch-sha-${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
check-if-pr-comment: | |
name: Check if this is a PR comment | |
runs-on: ubuntu-latest | |
if: (github.event_name != 'issue_comment') || ((github.event_name == 'issue_comment') && (github.event.comment.body == '/report sha!')) | |
outputs: | |
is-pr-comment: ${{ steps.determine-if-pr-comment.outputs.is-pr }} | |
steps: | |
- id: determine-if-pr-comment | |
run: | | |
if [ -z "${{ github.event.issue.pull_request }}" ] \ | |
then \ | |
echo "is-pr=true" >> "${GITHUB_OUTPUT}" \ | |
else \ | |
echo "is-pr=false" >> "${GITHUB_OUTPUT}" \ | |
fi | |
set-variables: | |
name: Create unique output file identifier and artifact name | |
runs-on: ubuntu-latest | |
needs: check-if-pr-comment | |
outputs: | |
sha: ${{ steps.determine-correct-sha.outputs.result }} | |
steps: | |
- id: determine-correct-sha | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
if (!${{ needs.check-if-pr-comment.outputs.is-pr-comment }}) { | |
return context.sha; | |
}; | |
const { data: pr } = await github.rest.pulls.get({ | |
owner: context.issue.owner, | |
repo: context.issue.repo, | |
pull_number: context.issue.number, | |
}); | |
return pr.head.sha; | |
report-sha: | |
name: Report SHA that was recovered | |
runs-on: ubuntu-latest | |
needs: set-variables | |
steps: | |
- name: Report SHA | |
run: | | |
echo "name=${GITHUB_EVENT_NAME}" | |
echo "SHA=${{ needs.set-variables.outputs.sha }}" |