11name : Gravity
22
33on :
4- push :
5- branches :
6- - main
7- pull_request : {}
4+ workflow_run :
5+ workflows : ["Build"]
6+ types :
7+ - completed
88
99jobs :
10- build :
10+ gravity :
1111 name : Run Gravity
1212 runs-on : ubuntu-latest
13- if : github.repository == 'mainmatter/gerust'
13+ if : >
14+ github.event.workflow_run.conclusion == 'success'
1415 steps :
1516 - uses : actions/checkout@v4
1617 - uses : pnpm/action-setup@v4
1718 with :
1819 version : 10
19- - uses : actions-rust-lang/setup-rust-toolchain@v1
20- - run : cargo publish --dry-run
21- - run : cargo build -r
22- - run : pnpm dlx @gravityci/cli "./target/release/gerust" "./target/package/gerust-*.crate" # keep track of the sizes of both the .crate file as well as the binary
20+ - uses : actions/download-artifact@v5
21+ with :
22+ github-token : ${{ github.token }}
23+ repository : ${{ github.repository }}
24+ run-id : ${{ github.event.workflow_run.id }}
25+ name : artifacts
26+ path : artifacts
27+ - name : ' Get PR context'
28+ if : >
29+ github.event.workflow_run.event == 'pull_request'
30+ id : pr-context
31+ env :
32+ GH_TOKEN : ${{ github.token }}
33+ PR_TARGET_REPO : ${{ github.repository }}
34+ PR_BRANCH : |-
35+ ${{
36+ (github.event.workflow_run.head_repository.owner.login != github.event.workflow_run.repository.owner.login)
37+ && format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
38+ || github.event.workflow_run.head_branch
39+ }}
40+ run : |
41+ gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
42+ --json 'number,headRefOid' \
43+ --jq '"number=\(.number)\nhead-sha=\(.headRefOid)"' \
44+ >> $GITHUB_OUTPUT
45+ - run : pnpm dlx @gravityci/cli "artifacts" # keep track of the sizes of both the .crate file as well as the binary
2346 env :
24- GRAVITY_TOKEN : ${{ secrets.GRAVITY_TOKEN }}
47+ GRAVITY_SHA : ${{ github.event.workflow_run.head_sha }}
48+ GRAVITY_PR_ID : ${{ github.event.workflow_run.event == 'pull_request' && steps.pr-context.outputs.number || '' }}
49+ GRAVITY_TOKEN : ${{ secrets.GRAVITY_TOKEN }}
0 commit comments