-
Notifications
You must be signed in to change notification settings - Fork 441
59 lines (51 loc) · 2.27 KB
/
submit-contract-sizes.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
# The workflow has write access, so it needs to be isolated for security reasons from pull request-based workflows,
# which may be triggered from forked repositories.
name: continuous-intergration/submit-contract-sizes
on:
workflow_run:
workflows:
- continuous-integration
types:
- completed
jobs:
submit-contract-sizes:
permissions:
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 5
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 100
- name: Download Master Contract Sizes
uses: ./.github/download-artifact
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: contract-sizes-master-data
- name: Download Pull-Request Contract Sizes
uses: ./.github/download-artifact
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: contract-sizes-pull_request-data
- name: Collect Contract Sizes
run: |
# Build the comparison table
./scripts/contract_sizes_diff.sh master_contract_sizes pull_request_contract_sizes > contract_sizes_diff.md
cat contract_sizes_diff.md
- name: Submit Comment
env:
GITHUB_PR_TOKEN: ${{ secrets.github_token }}
GITHUB_PR_WORKFLOW_ID: ${{ github.event.workflow_run.id }}
run: |
# context.out is considered as an untrusted file
PR_NUMBER=$(grep -oE 'PR_NUMBER="[^"]+"' context.out | awk -F '"' '{print $2}')
CARGO_CONTRACT_VERSION=$(grep -oE 'CARGO_CONTRACT_VERSION="[^"]+"' context.out | awk -F '"' '{print $2}')
PR_COMMENTS_URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments"
WORKFLOW_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_PR_WORKFLOW_ID}"
# Submit the comparison table as a comment to the PR
echo "Submitting contract sizes diff to ${PR_COMMENTS_URL}"
GITHUB_PR_TOKEN=${GITHUB_PR_TOKEN} .github/scripts/contract_sizes_submit.sh ${PR_COMMENTS_URL} ${WORKFLOW_URL} ${CARGO_CONTRACT_VERSION} < ./contract_sizes_diff.md