Skip to content

Commit c10638a

Browse files
committed
Refactor upgrade workflow to include network type and enhance private key handling
1 parent 6841dbe commit c10638a

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

.github/workflows/upgrade.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,27 @@ name: Upgrade
22
on:
33
workflow_dispatch:
44
inputs:
5-
network:
6-
description: 'Network'
7-
required: true
8-
type: choice
9-
options:
10-
- hardhat
11-
- bellecour
5+
network_type:
6+
description: 'Network Type (mainnets or testnets)'
7+
required: true
8+
type: choice
9+
options:
10+
- mainnets
11+
- testnets
12+
network:
13+
description: 'Network'
14+
required: true
15+
type: choice
16+
options:
17+
- hardhat
18+
- bellecour
19+
- viviani
1220
jobs:
1321
upgrade:
1422
runs-on: ubuntu-latest
1523
permissions:
1624
contents: write # required by git-auto-commit-action
17-
environment: ${{ inputs.network }} # Secrets for an environment are already limited to deployments on specific branches
25+
environment: ${{ inputs.network_type }} # Secrets for an environment are already limited to deployments on specific branches
1826
steps:
1927
- name: Checkout
2028
uses: actions/checkout@v4
@@ -25,11 +33,26 @@ jobs:
2533
cache: 'npm'
2634
- name: Install dependencies
2735
run: npm ci
36+
- name: Set private key based on network
37+
id: set-private-key
38+
run: |
39+
case "${{ inputs.network }}" in
40+
"bellecour")
41+
echo "PRIVATE_KEY=${{ secrets.BELLECOUR_PRIVATE_KEY }}" >> $GITHUB_ENV
42+
;;
43+
"viviani")
44+
echo "PRIVATE_KEY=${{ secrets.VIVIANI_PRIVATE_KEY }}" >> $GITHUB_ENV
45+
;;
46+
*)
47+
echo "PRIVATE_KEY=''" >> $GITHUB_ENV
48+
;;
49+
esac
50+
2851
- name: Upgrade
2952
env:
3053
NETWORK: ${{ inputs.network }}
3154
IS_LOCAL_FORK: ${{ inputs.network == 'hardhat'}}
32-
PROD_PRIVATE_KEY: ${{ inputs.network == 'bellecour' && secrets.PROD_PRIVATE_KEY || '' }}
55+
PROD_PRIVATE_KEY: ${{ env.PRIVATE_KEY }}
3356
run: |
3457
echo "Network: $NETWORK"
3558
echo "Local fork: $IS_LOCAL_FORK"

0 commit comments

Comments
 (0)