-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add gha for merging prod into main (#715)
* feat: Add gha for merging prod into main * comment * add automerge functionality * new code that works * update title * semicolon --------- Co-authored-by: Masoud Amjadi <[email protected]>
- Loading branch information
1 parent
eea03e1
commit 21fed00
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,55 @@ jobs: | |
config: .github/config/slack.yml | ||
if: contains(toJson(github.event.commits.*.message), 'BREAKING CHANGE') | ||
|
||
# Step 12: Merge prod branch into main | ||
- name: Create PR to merge prod into main | ||
id: createpr | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const ownerAndRepo = '${{ github.repository }}'; | ||
const [owner, repo] = ownerAndRepo.split('/'); | ||
const head = "prod"; | ||
const base = "main"; | ||
const title = "feat: Merge prod into main"; | ||
const pr = await github.rest.pulls.list({owner, repo, base, head: `${owner}:${head}`}) | ||
if (pr.data.length>0) { | ||
return pr.data[0].number; | ||
} | ||
const result = await github.rest.pulls.create({ | ||
owner, | ||
repo, | ||
head, | ||
base, | ||
title, | ||
}); | ||
return result.data.number; | ||
# Step 13: Automerge PR | ||
- name: Enable Automerge PR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
uses: peter-evans/enable-pull-request-automerge@v3 | ||
with: | ||
pull-request-number: ${{steps.createpr.outputs.result}} | ||
merge-method: squash | ||
|
||
# Step 14: Generate token for autoapproving PR | ||
- name: Generate token | ||
id: generate_token | ||
uses: chanzuckerberg/[email protected] | ||
with: | ||
app_id: ${{ secrets.CZI_GITHUB_HELPER_APP_ID }} | ||
private_key: ${{ secrets.CZI_GITHUB_HELPER_PK }} | ||
|
||
# Step 15: Autoapprove PR | ||
- name: Autoapprove PR | ||
run: gh pr review --approve "${{steps.createpr.outputs.result}}" | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
|
||
# Job 2 | ||
create-version-matrix: | ||
needs: release | ||
|