Skip to content

Commit 47dcd99

Browse files
committed
Deploy using actions
1 parent 763f876 commit 47dcd99

File tree

2 files changed

+50
-54
lines changed

2 files changed

+50
-54
lines changed

.github/workflows/sharing-smart-contract-deploy.yml

Lines changed: 49 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,17 @@ jobs:
3131
- uses: actions/checkout@v4
3232
with:
3333
fetch-depth: 0
34-
- name: Validate mainnet deployment conditions
35-
# Use `mainnets` environment (wallet) only for mainnet deployments
36-
# and only from the main branch.
37-
# TODO update this when we have other mainnets
34+
35+
# On Github, the environment `mainnets` is restricted to
36+
# the main branch. Here we check that it's only used with
37+
# mainnet networks.
38+
- name: Validate mainnet deployment
3839
run: |
39-
if [[ \
40-
"${{ inputs.environment }}" == "mainnets" && \
41-
!("${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" == "refs/heads/main") \
42-
]]; then
43-
echo "::error::Bellecour mainnet deployments must be made from the main branch. Current branch: ${GITHUB_REF#refs/heads/}"
40+
if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" != "bellecour" ]]; then
41+
echo "::error::mainnets environment can only be used with mainnet networks."
4442
exit 1
4543
fi
46-
echo "Deployment validated!"
44+
echo "Deploying to:network ${{ inputs.network }} with ${{ inputs.environment }} environment."
4745
4846
# Build and test before deploying.
4947
ci:
@@ -60,54 +58,52 @@ jobs:
6058
contents: write # Required for saving deployment
6159
environment: ${{ inputs.environment }}
6260
steps:
63-
- name: Say Hello
64-
run: echo "Hello from env - ${{ inputs.environment }}"
65-
66-
# - uses: actions/checkout@v4
67-
# with:
68-
# fetch-depth: 0
61+
- name: Set environment variables
62+
id: set-env
63+
run: |
64+
echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV
6965
70-
# - uses: actions/setup-node@v4
71-
# with:
72-
# node-version: 18
73-
# cache: 'npm' # Cache dependencies
66+
if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then
67+
echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV
68+
fi
7469
75-
# - name: Install dependencies
76-
# run: npm ci
70+
if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
71+
echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV
72+
fi
7773
78-
# - name: Set environment variables
79-
# id: set-env
80-
# run: |
81-
# echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV
82-
# if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then
83-
# echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV
84-
# echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV
85-
# fi
74+
- uses: actions/checkout@v4
75+
with:
76+
fetch-depth: 0
8677

87-
# if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
88-
# echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV
89-
# echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV
90-
# fi
78+
- uses: actions/setup-node@v4
79+
with:
80+
node-version: 18
81+
cache: 'npm' # Cache dependencies
9182

92-
# if [ "${{ inputs.network }}" == "bellecour" ]; then
93-
# echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV
94-
# fi
83+
- name: Install dependencies
84+
working-directory: packages/sharing-smart-contract
85+
run: npm ci
9586

96-
# - name: Deploy contracts
97-
# run: |
98-
# echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment"
99-
# npm run deploy -- --network ${{ inputs.network }}
87+
- name: Deploy contracts
88+
working-directory: packages/sharing-smart-contract
89+
run: npm run deploy -- --network ${{ inputs.network }}
10090

101-
# - name: Update config.json with ERC1538Proxy address
102-
# if: inputs.network != 'hardhat'
103-
# run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }}
91+
- name: Save deployment artifacts and updated config
92+
if: inputs.network != 'hardhat'
93+
uses: stefanzweifel/git-auto-commit-action@v5
94+
with:
95+
commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})'
96+
file_pattern: 'packages/sharing-smart-contract/ignition/deployments/*'
97+
commit_user_name: 'GitHub Actions Bot'
98+
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
99+
commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
104100

105-
# - name: Save deployment artifacts and updated config
106-
# if: inputs.network != 'hardhat'
107-
# uses: stefanzweifel/git-auto-commit-action@v5
108-
# with:
109-
# commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})'
110-
# file_pattern: 'deployments/${{ inputs.network }}/* config/config.json'
111-
# commit_user_name: 'GitHub Actions Bot'
112-
# commit_user_email: 'github-actions[bot]@users.noreply.github.com'
113-
# commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
101+
# TODO
102+
# Verify contracts.
103+
verify:
104+
needs: deploy
105+
runs-on: ubuntu-latest
106+
steps:
107+
- name: Verify contracts
108+
working-directory: packages/sharing-smart-contract
109+
run: echo "Verify contracts"

packages/sharing-smart-contract/hardhat.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = {
111111
ignition: {
112112
strategyConfig: {
113113
create2: {
114-
salt: "0x5FD8F2C3DFCF36E174AC91A44AE6CAEBDDA012EFED601736E2C20A11A56CF533",
114+
salt: "0x5FD8F2C3DFCF36E174AC91A44AE6CAEBDDA012EFED601736E2C20A11A56CF534",
115115
},
116116
},
117117
},

0 commit comments

Comments
 (0)