From 1845a5d3fb130c8569d02ca7c8e741eb28036e1f Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 25 Sep 2024 12:36:58 -0400 Subject: [PATCH 1/5] first draft of workflow --- .github/workflows/deployment_pr.yml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/deployment_pr.yml diff --git a/.github/workflows/deployment_pr.yml b/.github/workflows/deployment_pr.yml new file mode 100644 index 00000000..99ac5ff5 --- /dev/null +++ b/.github/workflows/deployment_pr.yml @@ -0,0 +1,43 @@ +name: Create PR from staging to main + +on: + schedule: + # Run every Sunday at midnight + - cron: '0 0 * * 0' + workflow_dispatch: # Allow manual trigger + +jobs: + create-pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: staging # Ensure we're working with the staging branch + + - name: Set up git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Check if staging is ahead of main + id: check_diff + run: | + git fetch origin main + # Check if staging is ahead of main + if git rev-list --right-only --count main...staging > 0; then + echo "::set-output name=should_open_pr::true" + else + echo "::set-output name=should_open_pr::false" + fi + + - name: Create pull request + if: steps.check_diff.outputs.should_open_pr == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + base: main + head: staging + title: 'Merge staging into main' + body: 'This PR was automatically created by a scheduled workflow to merge staging into main.' From 285620b3c8df670f76e33b29ee485b248b7ce3f4 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 25 Sep 2024 12:39:28 -0400 Subject: [PATCH 2/5] test workflow --- .github/workflows/deployment_pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment_pr.yml b/.github/workflows/deployment_pr.yml index 99ac5ff5..2a713296 100644 --- a/.github/workflows/deployment_pr.yml +++ b/.github/workflows/deployment_pr.yml @@ -37,7 +37,7 @@ jobs: uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} - base: main - head: staging + base: staging + head: lebovits/issu849-weekly-deployment-PR title: 'Merge staging into main' body: 'This PR was automatically created by a scheduled workflow to merge staging into main.' From 95a80a055c7652fc582c7c8d815469046495e06c Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 25 Sep 2024 12:42:07 -0400 Subject: [PATCH 3/5] fix syntax issue --- .github/workflows/deployment_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment_pr.yml b/.github/workflows/deployment_pr.yml index 2a713296..086713f6 100644 --- a/.github/workflows/deployment_pr.yml +++ b/.github/workflows/deployment_pr.yml @@ -38,6 +38,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} base: staging - head: lebovits/issu849-weekly-deployment-PR + branch: lebovits/issu849-weekly-deployment-PR title: 'Merge staging into main' body: 'This PR was automatically created by a scheduled workflow to merge staging into main.' From cdeb7a3a9ac1e86e918136f8590c190fa0914669 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 25 Sep 2024 12:44:25 -0400 Subject: [PATCH 4/5] add permissions --- .github/workflows/deployment_pr.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deployment_pr.yml b/.github/workflows/deployment_pr.yml index 086713f6..a8de4d7a 100644 --- a/.github/workflows/deployment_pr.yml +++ b/.github/workflows/deployment_pr.yml @@ -1,5 +1,9 @@ name: Create PR from staging to main +permissions: + contents: write + pull-requests: write + on: schedule: # Run every Sunday at midnight From 3ab596c8e4e41032f1b8fcfc42e6fe29368d0fd8 Mon Sep 17 00:00:00 2001 From: nlebovits Date: Wed, 25 Sep 2024 12:57:28 -0400 Subject: [PATCH 5/5] test basic workflow --- .github/workflows/deployment_pr.yml | 46 +++-------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/.github/workflows/deployment_pr.yml b/.github/workflows/deployment_pr.yml index a8de4d7a..6634c89c 100644 --- a/.github/workflows/deployment_pr.yml +++ b/.github/workflows/deployment_pr.yml @@ -1,47 +1,9 @@ -name: Create PR from staging to main - -permissions: - contents: write - pull-requests: write - +name: Test Workflow on: - schedule: - # Run every Sunday at midnight - - cron: '0 0 * * 0' - workflow_dispatch: # Allow manual trigger + workflow_dispatch: jobs: - create-pr: + test: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: staging # Ensure we're working with the staging branch - - - name: Set up git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Check if staging is ahead of main - id: check_diff - run: | - git fetch origin main - # Check if staging is ahead of main - if git rev-list --right-only --count main...staging > 0; then - echo "::set-output name=should_open_pr::true" - else - echo "::set-output name=should_open_pr::false" - fi - - - name: Create pull request - if: steps.check_diff.outputs.should_open_pr == 'true' - uses: peter-evans/create-pull-request@v7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - base: staging - branch: lebovits/issu849-weekly-deployment-PR - title: 'Merge staging into main' - body: 'This PR was automatically created by a scheduled workflow to merge staging into main.' + - run: echo "Workflow is running!"