Skip to content

Commit

Permalink
Check PR against solution branch
Browse files Browse the repository at this point in the history
  • Loading branch information
edeandrea committed Dec 6, 2024
1 parent 7611ea3 commit 5c17c11
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: ./mvnw -B clean verify -Dmaven.compiler.release=${{ matrix.java }}

check-commit-against-solution-branch:
if: (github.actor == 'dependabot[bot]') && (github.repository == 'RedHat-Middleware-Workshops/spring-jkube-external-config') && (github.event_name == 'pull_request')
if: (github.event_name == 'pull_request') && (github.repository == 'RedHat-Middleware-Workshops/spring-jkube-external-config') && ((github.actor == 'dependabot[bot]') || (github.event.pull_request.user.login == 'dependabot[bot]'))
strategy:
fail-fast: false
matrix:
Expand All @@ -60,4 +60,5 @@ jobs:
secrets: inherit
with:
java_version: ${{ matrix.java }}
ref: ${{ github.ref }}
pr_num: ${{ github.event.pull_request.number }}
pr_head_ref: ${{ github.head_ref }}
26 changes: 22 additions & 4 deletions .github/workflows/check-against-solution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Check PR against solution branch
on:
workflow_call:
inputs:
ref:
description: The ref from the PR branch
pr_num:
description: The PR Number
required: true
type: string
pr_head_ref:
description: The PR head ref
required: true
type: string
java_version:
Expand All @@ -17,6 +21,10 @@ concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

defaults:
run:
shell: bash

jobs:
check-commit-against-solution-branch:
runs-on: ubuntu-latest
Expand All @@ -26,12 +34,21 @@ jobs:
- uses: actions/checkout@v4
with:
ref: solution
path: src

- name: Get PR diff
run: wget ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/pull/${{ inputs.pr_num }}.diff

- name: Apply change
run: git merge --squash --stat ${{ inputs.ref }}
working-directory: src
run: git apply --stat -v ../${{ inputs.pr_num }}.diff
# run: |
# git fetch origin pull/${{ inputs.pr_num }}/head:${{ inputs.pr_head_ref }}
# git merge --squash --stat ${{ inputs.ref }}

- name: Show diff
run: git diff main
working-directory: src
run: git status

- name: Setup Java ${{ inputs.java_version }}
uses: actions/setup-java@v4
Expand All @@ -41,4 +58,5 @@ jobs:
cache: maven

- name: Run build and tests with Java ${{ inputs.java_version }}
working-directory: src
run: ./mvnw -B clean verify -Dmaven.compiler.release=${{ inputs.java_version }}

0 comments on commit 5c17c11

Please sign in to comment.