-
Notifications
You must be signed in to change notification settings - Fork 69
54 lines (48 loc) · 1.69 KB
/
weekly-pr-to-main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Open PR from Staging to Main
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight
workflow_dispatch: # Allows manual triggering
inputs:
branch:
description: 'The branch to create the PR from'
required: true
default: 'staging'
jobs:
open-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Check if staging is ahead of main
id: check_diff
run: |
git fetch origin main
git fetch origin staging
if [ $(git rev-list --count main..staging) -gt 0 ]; then
echo "staging is ahead"
echo "::set-output name=staging_ahead::true"
else
echo "staging is not ahead"
echo "::set-output name=staging_ahead::false"
fi
shell: bash
- name: Open PR if staging is ahead
if: steps.check_diff.outputs.staging_ahead == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
branch: staging
title: 'Weekly PR from Staging to Main'
body: 'Automated PR to merge staging into main. This PR was generated as part of the weekly process.'
labels: 'automated-pr'
commit-message: '[create-pull-request] Merge staging into main'
draft: false
- name: Skip PR if no changes
if: steps.check_diff.outputs.staging_ahead == 'false'
run: echo "No changes to merge from staging to main."