Skip to content

Commit

Permalink
Testing check-if-branch-is-ahead-of-main (#4656)
Browse files Browse the repository at this point in the history
* Testing check-if-branch-is-ahead-of-main

* Comment on PR if this status runs and fails

* Add merge_group: to event list

* Force to main branch

* Force to run only on pull request events

* Revert

* Add merge queue file

---------

Co-authored-by: Alex Steel <[email protected]>
  • Loading branch information
sambodeme and asteel-gsa authored Jan 28, 2025
1 parent 34f4a21 commit a5c83d6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/on-merge-queue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Merge Queue Push
on:
merge_group:
branches:
- main

jobs:
merge-queue:
runs-on: ubuntu-latest
steps:
- name: "Entering Merge Queue"
run: echo "Merge queue has been activated"
26 changes: 24 additions & 2 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
- '!.github/ISSUE_TEMPLATE/**'
workflow_dispatch: null

env:
GH_TOKEN: ${{ github.token }}

jobs:
check-for-changes:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -39,20 +42,37 @@ jobs:
staticfiles:
- './backend/static/**'
check-if-branch-is-ahead-of-main:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if branch is ahead of main
run: |
if ! git merge-base --is-ancestor origin/main ${{ github.event.pull_request.head.sha }};
then echo "This branch is not up to date with main";
gh pr comment ${{ github.event.pull_request.number }} \
--body "This pull request is not up to date with main. Please merge main into this brach or rebase this branch onto main. This PR should not be approved until all status checks pass. If you see this message, please rerun all status checks before merging."
exit 1; fi
# Tests and Linting invoked on a Pull Request
testing-from-build:
needs: [check-for-changes]
needs: [check-for-changes, check-if-branch-is-ahead-of-main]
if: ${{ needs.check-for-changes.outputs.requirements == 'true' || needs.check-for-changes.outputs.dev-requirements == 'true' || needs.check-for-changes.outputs.docker == 'true' || needs.check-for-changes.outputs.package == 'true' || needs.check-for-changes.outputs.staticfiles == 'true' }}
uses: ./.github/workflows/testing-from-build.yml
secrets: inherit

testing-from-ghcr:
needs: [check-for-changes]
needs: [check-for-changes, check-if-branch-is-ahead-of-main]
if: ${{ needs.check-for-changes.outputs.requirements != 'true' && needs.check-for-changes.outputs.dev-requirements != 'true' && needs.check-for-changes.outputs.docker != 'true' && needs.check-for-changes.outputs.package != 'true' && needs.check-for-changes.outputs.staticfiles != 'true' }}
uses: ./.github/workflows/testing-from-ghcr.yml
secrets: inherit

linting:
needs: [check-if-branch-is-ahead-of-main]
uses: ./.github/workflows/linting.yml
secrets: inherit

Expand All @@ -65,13 +85,15 @@ jobs:

# Generate Terraform Plans
terraform-plan:
needs: [check-if-branch-is-ahead-of-main]
if: ${{ github.base_ref == 'main' }}
uses: ./.github/workflows/terraform-plan-env.yml
with:
environment: "dev"
secrets: inherit

terraform-plan-meta:
needs: [check-if-branch-is-ahead-of-main]
if: ${{ github.base_ref == 'main' }}
uses: ./.github/workflows/terraform-plan-env.yml
with:
Expand Down

0 comments on commit a5c83d6

Please sign in to comment.