|
37 | 37 | contents: write # Required to commit deployment files. |
38 | 38 | env: |
39 | 39 | 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 | + |
40 | 46 | steps: |
41 | 47 | - name: Validate deployment environment |
42 | 48 | if: inputs.network != 'hardhat' |
@@ -94,15 +100,29 @@ jobs: |
94 | 100 | DEPLOYMENT_ID="$DEPLOYMENT_ID" \ |
95 | 101 | npm run deploy -- --network ${{ inputs.network }} |
96 | 102 |
|
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' |
99 | 105 | uses: stefanzweifel/git-auto-commit-action@v5 |
100 | 106 | with: |
101 | | - commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} ${{ inputs.stage }} (${{ github.run_id }})' |
| 107 | + commit_message: ${{ env.COMMIT_MESSAGE }} |
102 | 108 | 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 |
106 | 126 |
|
107 | 127 | - name: Verify contracts |
108 | 128 | if: inputs.network != 'hardhat' |
|
0 commit comments