File tree Expand file tree Collapse file tree 3 files changed +86
-1
lines changed Expand file tree Collapse file tree 3 files changed +86
-1
lines changed Original file line number Diff line number Diff line change 33 pull_request :
44
55jobs :
6+ # Check if we need to run contract-related jobs
7+ check-changes :
8+ name : Check for relevant changes
9+ runs-on : ubuntu-latest
10+ outputs :
11+ should-run-contracts : ${{ steps.changes.outputs.contracts }}
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 0
17+
18+ - name : Check for changes
19+ uses : dorny/paths-filter@v3
20+ id : changes
21+ with :
22+ filters : |
23+ contracts:
24+ - 'common/**'
25+ - 'contract/**'
26+ - 'mock/**'
27+ - 'script/**'
28+
629 test :
730 uses : ./.github/workflows/test.yml
831
932 gas-report :
33+ needs : check-changes
34+ if : needs.check-changes.outputs.should-run-contracts == 'true'
1035 uses : ./.github/workflows/gas-report.yml
1136
1237 deploy-staging :
1338 name : Deploy to staging subaccount
1439 permissions :
1540 pull-requests : write
16- needs : [test, gas-report]
41+ needs : [test, gas-report, check-changes]
42+ # Run if contracts changed OR if gas-report was skipped
43+ if : always() && needs.test.result == 'success' && (needs.gas-report.result == 'success' || needs.gas-report.result == 'skipped')
1744 runs-on : ubuntu-latest
1845 env :
1946 NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID : gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
Original file line number Diff line number Diff line change 77 value : ${{ jobs.gas-report.outputs.comment }}
88
99jobs :
10+ # Add a job to check if relevant files changed
11+ check-changes :
12+ name : Check for relevant changes
13+ runs-on : ubuntu-latest
14+ outputs :
15+ should-run : ${{ steps.changes.outputs.contracts }}
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0 # Needed for change detection
21+
22+ - name : Check for changes
23+ uses : dorny/paths-filter@v3
24+ id : changes
25+ with :
26+ filters : |
27+ contracts:
28+ - 'common/**'
29+ - 'contract/**'
30+ - 'mock/**'
31+ - 'script/**'
32+
1033 gas-report :
1134 name : Gas report
1235 runs-on : ubuntu-latest
36+ needs : check-changes
37+ # Only run if there are relevant changes
38+ if : needs.check-changes.outputs.should-run == 'true'
1339 outputs :
1440 comment : ${{ steps.generate.outputs.comment }}
1541 steps :
Original file line number Diff line number Diff line change 44 types : [closed]
55
66jobs :
7+ # Check if a staging environment was actually created (contract changes existed)
8+ check-staging-exists :
9+ name : Check if staging environment exists
10+ runs-on : ubuntu-latest
11+ outputs :
12+ should-cleanup : ${{ steps.check.outputs.exists }}
13+ env :
14+ NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID : gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+
19+ - name : Check if staging account exists
20+ id : check
21+ run : |
22+ # Install near CLI for account checking
23+ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.22.0/near-cli-rs-installer.sh | sh
24+
25+ EXISTS=$(./script/ci/account-exists.sh \
26+ --account "${{ env.NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID }}" \
27+ --network "${{ vars.NEAR_CONTRACT_STAGING_NETWORK }}" || echo "")
28+
29+ if [[ -n "$EXISTS" ]]; then
30+ echo "exists=true" >> $GITHUB_OUTPUT
31+ echo "Staging account exists, will proceed with cleanup"
32+ else
33+ echo "exists=false" >> $GITHUB_OUTPUT
34+ echo "Staging account does not exist, skipping cleanup"
35+ fi
36+
737 cleanup-staging :
838 name : Cleanup staging account
939 runs-on : ubuntu-latest
40+ needs : check-staging-exists
41+ if : needs.check-staging-exists.outputs.should-cleanup == 'true'
1042 env :
1143 NEAR_CONTRACT_PR_STAGING_ACCOUNT_ID : gh-${{ github.event.number }}.${{ vars.NEAR_CONTRACT_STAGING_ACCOUNT_ID }}
1244 steps :
You can’t perform that action at this time.
0 commit comments