-
Notifications
You must be signed in to change notification settings - Fork 13
106 lines (94 loc) · 3.9 KB
/
deploy.yml
File metadata and controls
106 lines (94 loc) · 3.9 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
name: Deploy PoCo Contracts
on:
workflow_dispatch:
inputs:
network:
description: 'Network'
required: true
type: choice
options:
- hardhat
- arbitrumSepolia
- arbitrum
- bellecour
default: 'hardhat'
jobs:
pre-deploy:
uses: ./.github/workflows/main.yml
deploy:
needs: pre-deploy
runs-on: ubuntu-latest
environment: ${{ inputs.network }} # Use the selected environment
permissions:
contents: write # Required to commit artifacts.
pull-requests: write # Required to create pull requests.
env:
# For commit action
COMMIT_MESSAGE: 'chore: Save deployment artifacts - ${{ inputs.network }} (runId:${{ github.run_id }})'
GHA_BOT_NAME: 'GitHub Actions Bot'
GHA_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Nodejs
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm' # Cache dependencies
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
# TODO activate later.
# Checks of initial state fails (e.g., balanceOf(proxyAddress) !== 0).
# - name: Run fork tests
# run: |
# if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
# npm run test:arbitrumSepolia
# fi
- name: Deploy contracts
env:
# Note: it is required to define both private key env variables when calling Hardhat.
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
RPC_URL: ${{ secrets.RPC_URL }}
EXPLORER_API_KEY: ${{ secrets.EXPLORER_API_KEY }}
run: npm run deploy -- --network ${{ inputs.network }}
- name: Update config.json with Diamond address
if: inputs.network != 'hardhat'
env:
# Note: it is required to define both private key env variables when calling Hardhat.
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }}
run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }}
- name: Push artifacts to the current branch
if: inputs.network != 'hardhat' && github.ref != 'refs/heads/main'
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: |
config/config.json
deployments/${{ inputs.network }}/
commit_message: ${{ env.COMMIT_MESSAGE }}
commit_user_name: ${{ env.GHA_BOT_NAME }}
commit_user_email: ${{ env.GHA_BOT_EMAIL }}
commit_author: '${{ env.GHA_BOT_NAME }} <${{ env.GHA_BOT_EMAIL }}>'
# Since the `main` branch is protected, create a PR to push artifacts.
- name: Push artifacts through a pull request
if: inputs.network != 'hardhat' && github.ref == 'refs/heads/main'
uses: peter-evans/create-pull-request@v7
with:
add-paths: |
config/config.json
deployments/${{ inputs.network }}/
commit-message: ${{ env.COMMIT_MESSAGE }}
committer: '${{ env.GHA_BOT_NAME }} <${{ env.GHA_BOT_EMAIL }}>'
author: '${{ env.GHA_BOT_NAME }} <${{ env.GHA_BOT_EMAIL }}>'
branch: chore/save-deploy-artifacts-${{ inputs.network }}-${{ github.run_id }}
title: ${{ env.COMMIT_MESSAGE }}
body: |
🤖 This is an automated pull request created by `${{ github.workflow }}` GitHub Actions
workflow to save deployment artifacts.
* Network: `${{ inputs.network }}`
* Run: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Note**: Verify deployment before merging this PR.
draft: true