Skip to content

Merge main into staging #311

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

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/merge-main-into-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Merge main into staging

on:
push:
branches:
- main

permissions:
contents: write
id-token: write
pull-requests: write

jobs:
merge-main-into-staging:
runs-on: ubuntu-latest

steps:
- name: Checkout staging branch
uses: actions/checkout@v3
with:
ref: staging

- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Merge in main branch
run: |
git fetch origin main:main
git merge main --no-ff --allow-unrelated-histories --strategy-option theirs -m "Merging latest changes from main into staging"

- name: Create pull request
id: pr-number
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-staging-${{ github.run_id }}
title: 'Merge main into staging'
body: 'Automatically merge main into staging branch.'

- name: Merge pull request
if: ${{ steps.pr-number.outputs.pull-request-number != '' }}
run: gh pr merge --merge --auto "${{ steps.pr-number.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete pull request branch
if: ${{ success() && steps.pr-number.outputs.pull-request-number != '' }}
run: gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/update-staging-${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}