From 1d28889a8d8644fd147e4c2801781aa328688413 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 2 Oct 2024 13:22:15 -0400 Subject: [PATCH 1/4] fix deprecated syntax --- .github/workflows/weekly-pr-to-main.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/weekly-pr-to-main.yml b/.github/workflows/weekly-pr-to-main.yml index 3abfa32d..993a380b 100644 --- a/.github/workflows/weekly-pr-to-main.yml +++ b/.github/workflows/weekly-pr-to-main.yml @@ -23,22 +23,21 @@ jobs: git config user.email "actions@github.com" - name: Check if staging is ahead of main - id: check_diff + id: check_diff # Fix indentation here 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" + echo "staging_ahead=true" >> $GITHUB_OUTPUT else echo "staging is not ahead" - echo "::set-output name=staging_ahead::false" - fi + echo "staging_ahead=false" >> $GITHUB_OUTPUT shell: bash - name: Open PR if staging is ahead if: steps.check_diff.outputs.staging_ahead == 'true' - uses: peter-evans/create-pull-request@v7 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} base: main From 95bb22d1261472c86b595f693b70a2c5d5fc80f3 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 2 Oct 2024 13:25:54 -0400 Subject: [PATCH 2/4] another syntax fix for bash script --- .github/workflows/weekly-pr-to-main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/weekly-pr-to-main.yml b/.github/workflows/weekly-pr-to-main.yml index 993a380b..a581b5a6 100644 --- a/.github/workflows/weekly-pr-to-main.yml +++ b/.github/workflows/weekly-pr-to-main.yml @@ -16,6 +16,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all branches and tags - name: Set up Git run: | @@ -23,21 +25,21 @@ jobs: git config user.email "actions@github.com" - name: Check if staging is ahead of main - id: check_diff # Fix indentation here + id: check_diff run: | - git fetch origin main - git fetch origin staging - if [ $(git rev-list --count main..staging) -gt 0 ]; then + git fetch origin main staging + if [ $(git rev-list --count origin/main..origin/staging) -gt 0 ]; then echo "staging is ahead" echo "staging_ahead=true" >> $GITHUB_OUTPUT else echo "staging is not ahead" echo "staging_ahead=false" >> $GITHUB_OUTPUT + fi shell: bash - name: Open PR if staging is ahead if: steps.check_diff.outputs.staging_ahead == 'true' - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} base: main From 86d0bd4394dc1cf336218d392b3ebb2f17502077 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 2 Oct 2024 13:30:22 -0400 Subject: [PATCH 3/4] try different approach --- .github/workflows/weekly-pr-to-main.yml | 30 ++++++++----------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/weekly-pr-to-main.yml b/.github/workflows/weekly-pr-to-main.yml index a581b5a6..1addbe6c 100644 --- a/.github/workflows/weekly-pr-to-main.yml +++ b/.github/workflows/weekly-pr-to-main.yml @@ -4,11 +4,6 @@ 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: @@ -19,11 +14,6 @@ jobs: with: fetch-depth: 0 # Fetch all history for all branches and tags - - 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: | @@ -37,18 +27,16 @@ jobs: fi shell: bash - - name: Open PR if staging is ahead + - name: Create 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 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pr_url=$(gh pr create --base main --head 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." \ + --label "automated-pr") + echo "Pull request created: $pr_url" - name: Skip PR if no changes if: steps.check_diff.outputs.staging_ahead == 'false' From 7ac3bf923a4320a1ae757c4aa6249fafd2d60967 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 2 Oct 2024 13:31:48 -0400 Subject: [PATCH 4/4] remove label for pr --- .github/workflows/weekly-pr-to-main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/weekly-pr-to-main.yml b/.github/workflows/weekly-pr-to-main.yml index 1addbe6c..f6f538c4 100644 --- a/.github/workflows/weekly-pr-to-main.yml +++ b/.github/workflows/weekly-pr-to-main.yml @@ -34,8 +34,7 @@ jobs: run: | pr_url=$(gh pr create --base main --head 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." \ - --label "automated-pr") + --body "Automated PR to merge staging into main. This PR was generated as part of the weekly process.") echo "Pull request created: $pr_url" - name: Skip PR if no changes