Skip to content

Commit 9459134

Browse files
committed
ci: Create pull requests for main branch
1 parent 5cad18a commit 9459134

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
contents: write # Required to commit deployment files.
3838
env:
3939
CI: true
40+
# For commit action
41+
COMMIT_MESSAGE: 'chore: Save deployment artifacts for ${{ inputs.network }} ${{ inputs.stage }} (${{ github.run_id }})'
42+
GHA_BOT_NAME: 'GitHub Actions Bot'
43+
GHA_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
44+
# commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
45+
4046
steps:
4147
- name: Validate deployment environment
4248
if: inputs.network != 'hardhat'
@@ -94,15 +100,29 @@ jobs:
94100
DEPLOYMENT_ID="$DEPLOYMENT_ID" \
95101
npm run deploy -- --network ${{ inputs.network }}
96102
97-
- name: Save deployment artifacts
98-
if: inputs.network != 'hardhat'
103+
- name: Push deployment artifacts to the current branch
104+
if: inputs.network != 'hardhat' && github.ref != 'refs/heads/main'
99105
uses: stefanzweifel/git-auto-commit-action@v5
100106
with:
101-
commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} ${{ inputs.stage }} (${{ github.run_id }})'
107+
commit_message: ${{ env.COMMIT_MESSAGE }}
102108
file_pattern: 'packages/sharing-smart-contract/ignition/deployments/* packages/sharing-smart-contract/.openzeppelin/*'
103-
commit_user_name: 'GitHub Actions Bot'
104-
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
105-
commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
109+
commit_user_name: ${{ env.GHA_BOT_NAME }}
110+
commit_user_email: ${{ env.GHA_BOT_EMAIL }}
111+
commit_author: '${{ env.GHA_BOT_NAME }} <${{ env.GHA_BOT_EMAIL }}>'
112+
113+
# Since `main` branch is protected, create a PR to push deployment files.
114+
- name: Push deployment artifacts through a pull request
115+
if: inputs.network != 'hardhat' && github.ref == 'refs/heads/main'
116+
uses: peter-evans/create-pull-request@v7
117+
with:
118+
commit-message: ${{ env.COMMIT_MESSAGE }}
119+
add-paths: 'packages/sharing-smart-contract/ignition/deployments/* packages/sharing-smart-contract/.openzeppelin/*'
120+
committer: ${{ env.GHA_BOT_NAME }}
121+
author: '${{ env.GHA_BOT_NAME }} <${{ env.GHA_BOT_EMAIL }}>'
122+
branch: chore/save-deployment-artifacts
123+
title: ${{ env.COMMIT_MESSAGE }}
124+
body: 'PR created by "Create Pull Request" action.'
125+
draft: true
106126

107127
- name: Verify contracts
108128
if: inputs.network != 'hardhat'

0 commit comments

Comments
 (0)