Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add gha for merging prod into main #715

Merged
merged 11 commits into from
Dec 5, 2023
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant 🔥 !!! Thanks so much for auto merging the PR 🚀 💡 This is SO exciting!!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredible work, @alldoami! Thank you for your dedication and effort in putting this together. it's truly remarkable! 😍🥳🤩

- name: Autoapprove PR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh 😯
I had no idea we could auto-approve the PRs ⭐️
This is fantastic! Thanks for sharing 🥳

run: gh pr review --approve "${{steps.createpr.outputs.result}}"
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

# Job 2
create-version-matrix:
needs: release
Expand Down
Loading