Skip to content

Commit e47cd73

Browse files
committed
fix Gravity for forks
1 parent dab9273 commit e47cd73

2 files changed

Lines changed: 57 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request: {}
8+
9+
jobs:
10+
build:
11+
name: Build Release Artifacts
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions-rust-lang/setup-rust-toolchain@v1
16+
- run: cargo publish --dry-run
17+
- run: cargo build -r
18+
- uses: actions/upload-artifact@v4
19+
with:
20+
name: artifacts
21+
path: |
22+
./target/release/gerust
23+
./target/package/gerust-*.crate

.github/workflows/gravity.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
name: Gravity
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request: {}
4+
workflow_run:
5+
workflows: ["Build"]
6+
types:
7+
- completed
88

99
jobs:
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+
- name: 'Download artifact'
21+
uses: actions/github-script@v6
22+
with:
23+
script: |
24+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
run_id: context.payload.workflow_run.id,
28+
});
29+
30+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
31+
return artifact.name == "artifacts"
32+
})[0];
33+
34+
let download = await github.rest.actions.downloadArtifact({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
artifact_id: matchArtifact.id,
38+
});
39+
40+
let fs = require('fs');
41+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/artifacts.zip`, Buffer.from(download.data));
42+
43+
- run: pnpm dlx @gravityci/cli "artifacts" # keep track of the sizes of both the .crate file as well as the binary
2344
env:
24-
GRAVITY_TOKEN: ${{ secrets.GRAVITY_TOKEN }}
45+
GRAVITY_SHA: ${{ github.event.workflow_run.event == 'pull_request' && github.event.pull_request.id || '' }}
46+
GRAVITY_PR_ID: ${{ }}
47+
GRAVITY_TOKEN: ${{ secrets.GRAVITY_TOKEN }}

0 commit comments

Comments
 (0)