Skip to content

Commit

Permalink
Merge pull request #56 from Sillen00/47-workflow-merge-main-check-for…
Browse files Browse the repository at this point in the history
…-pull-requests

47 workflow merge main check for pull requests
  • Loading branch information
Sillen00 committed Dec 11, 2023
2 parents 2a967c1 + 0b79615 commit 2a77061
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,39 @@ on: #this workflow runs on pull requests and pushes to main or master

#this is a list of all jobs
jobs:
check-pr-sync-with-main:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Create and checkout a temporary branch from main
run: |
git fetch origin main
git checkout -b temp-branch origin/main
- name: Merge PR branch into temporary branch
run: |
git merge ${{ github.event.pull_request.head.sha }} --no-edit || true
- name: Check for differences
run: |
if git diff --exit-code ${{ github.event.pull_request.head.sha }} temp-branch; then
echo "No differences found. The PR branch is up-to-date with the latest main branch."
else
echo "Differences found. The PR branch is not up-to-date with the latest main branch."
exit 1
fi
linting:
runs-on: ubuntu-latest
needs: check-pr-sync-with-main
steps:
- name: Checkout #checks out our current branch so this runner has the latest code
uses: actions/checkout@v4 #uses means that it is a pre-defined action supplied by GitHub.
Expand All @@ -28,7 +59,7 @@ jobs:

testing: #name of first job
runs-on: ubuntu-latest #sets the env which this job runs on
needs: linting
needs: [linting, check-pr-sync-with-main]
steps: #defines the steps necessary
- name: Checkout #checks out our current branch so this runner has the latest code
uses: actions/checkout@v4 #uses means that it is a pre-defined action supplied by GitHub.
Expand Down

0 comments on commit 2a77061

Please sign in to comment.