Repository navigation
89 lines (76 loc) · 2.81 KB
/
Copy pathdeploy-testnet.yml
File metadata and controls
89 lines (76 loc) · 2.81 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
name: Deploy to Testnet
on:
push:
branches: [main]
paths:
- 'contracts/**'
- 'scripts/deploy.sh'
- 'scripts/initialize.sh'
- '.github/workflows/deploy-testnet.yml'
permissions:
contents: write
jobs:
deploy:
name: Deploy Contracts
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
# Cache workspace crates in addition to dependencies for faster rebuilds
cache-workspace-crates: "true"
# A prebuilt release binary, instead of compiling the CLI from source.
- name: Install Stellar CLI
uses: stellar/stellar-cli@v28.1.0
- name: Build contract WASMs
run: cargo build --release --target wasm32-unknown-unknown
# The deployer key is a stable repository secret, so every deployment is
# owned by a key the team holds and admin functions stay usable.
- name: Import deployer identity
env:
STELLAR_DEPLOYER_SECRET: ${{ secrets.STELLAR_DEPLOYER_SECRET }}
run: |
if [ -z "$STELLAR_DEPLOYER_SECRET" ]; then
echo "::error::Repository secret STELLAR_DEPLOYER_SECRET is not set"
exit 1
fi
echo "$STELLAR_DEPLOYER_SECRET" | stellar keys add pulsartrack-deployer --secret-key
- name: Run deployment script
run: ./scripts/deploy.sh --force
env:
STELLAR_NETWORK: testnet
STELLAR_IDENTITY: pulsartrack-deployer
# The deployer identity is the admin, so the contracts come up initialized
# with a known admin instead of being left unadministrable.
- name: Initialize contracts
run: ./scripts/initialize.sh --network testnet --identity pulsartrack-deployer
env:
STELLAR_NETWORK: testnet
STELLAR_IDENTITY: pulsartrack-deployer
- name: Commit and push deployment records
run: |
git config user.name "deploy-bot"
git config user.email "deploy@pulsartrack.local"
git add deployments/
if ! git diff --cached --exit-code > /dev/null; then
git commit -m "chore: update deployment records for $STELLAR_NETWORK"
for attempt in 1 2 3; do
if git push origin HEAD:main; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "::error::Failed to push deployment records after $attempt attempts"
exit 1
fi
git fetch origin main
git rebase origin/main
done
else
echo "No deployment record changes to commit"
fi