-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (95 loc) · 3.89 KB
/
artifacts.yml
File metadata and controls
107 lines (95 loc) · 3.89 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Sync Contract Artifacts
on:
workflow_call:
inputs:
protocol_ref:
description: Branch tag to checkout for otim-protocol
type: string
default: main
offchain_ref:
description: Branch tag to checkout for otim-offchain
type: string
default: main
secrets:
GH_APP_ID:
description: GitHub App ID for token generation
required: true
GH_APP_PRIVATE_KEY:
description: GitHub App private key for token generation
required: true
outputs:
artifacts_match:
description: Whether artifacts match between repositories
value: ${{ jobs.sync-artifacts.outputs.artifacts_match }}
permissions:
contents: write
id-token: write
jobs:
sync-artifacts:
name: Sync Contract Artifacts
runs-on: ubuntu-latest
outputs:
artifacts_match: ${{ steps.compare-artifacts.outputs.artifacts_match }}
steps:
- name: Generate GitHub App Token
id: bot_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Checkout protocol
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.protocol_ref || 'main' }}
- name: Checkout offchain
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: otimlabs/otim-offchain
token: ${{ steps.bot_token.outputs.token }}
path: offchain
ref: ${{ inputs.offchain_ref || 'main' }}
- name: Install foundry
uses: foundry-rs/foundry-toolchain@8789b3e21e6c11b2697f5eb56eddae542f746c10 # v1.7.0
with:
version: stable
cache-key: ${{ github.job }}-${{ github.sha }}
- name: Build protocol
id: build-protocol
run: |
echo "protocol_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
forge soldeer update
forge build --sizes
- name: Install rust-script
run: |
curl -LsSf https://github.com/fornwall/rust-script/releases/latest/download/rust-script-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
sudo install rust-script /usr/local/bin/
- name: Compare and sync artifacts
id: compare-artifacts
run: |
if ./.github/deployment/scripts/protocol-cli.rs compare-directories "./out" "./offchain/crates/contracts/artifacts" --ignore "build-info" --show-diff 2>&1; then
echo "artifacts_match=true" >> $GITHUB_OUTPUT
echo "✅ Artifacts match"
else
echo "artifacts_match=false" >> $GITHUB_OUTPUT
echo "❌ Artifacts differ - syncing"
# Prepare offchain for artifact sync
cd ./offchain
rm -rf ./crates/contracts/artifacts
cp -r ../out ./crates/contracts/artifacts
fi
- name: Create artifact sync PR
if: steps.compare-artifacts.outputs.artifacts_match == 'false'
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ steps.bot_token.outputs.token }}
path: ./offchain
commit-message: "sync: otim-protocol artifacts (${{ steps.build-protocol.outputs.protocol_sha }})"
title: "Sync: otim-protocol build artifacts"
body: |
Syncing build artifacts from otim-protocol ([artifact comparison](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}))
- Protocol: `${{ steps.build-protocol.outputs.protocol_sha }}`
- Offchain: `${{ inputs.offchain_ref || 'main' }}`
branch: chore/sync-artifacts
branch-suffix: short-commit-hash
base: ${{ inputs.offchain_ref || 'main' }}
delete-branch: false