-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (56 loc) · 1.89 KB
/
fetch_sha.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 }} == "true") {
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;
};
return context.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 }}"