Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
chore: move commit check into the same job as the build as it seems e…
Browse files Browse the repository at this point in the history
…nv vars do not cross job boundaries; remove dep on other job (#176)

Signed-off-by: Nick Boldt <nboldt@redhat.com>
  • Loading branch information
nickboldt committed Jan 29, 2024
1 parent 9e716fa commit fc37ff4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/next-container-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
# don't fail if nothing returned by grep
set +e
CHANGES="$(git diff --name-only HEAD~1 | \
grep -E "workflows/.+-container-build.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go|docker/|\.dockerignore" | \
grep -v -E ".+_test.go|/.rhdh/")";
grep -E "workflows/.+-container-build.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go|docker/|\.dockerignore" | \
grep -v -E ".+_test.go|/.rhdh/")";
echo "Changed files for this commit:"
echo "=============================="
echo "$CHANGES"
Expand Down
35 changes: 12 additions & 23 deletions .github/workflows/pr-container-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,31 @@ jobs:
run: |
echo "✓"
check-changes:
# check if the change for this PR necessitates a rebuild of containers
pr-build:
name: PR Publish
runs-on: ubuntu-latest
needs: authorize
permissions:
contents: read
packages: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: check-changes
# check changes in this commit for regex include and exclude matches; pipe to an env var

# check changes in this commit for regex include and exclude matches; pipe to an env var
- name: Check for changes to build
run: |
# don't fail if nothing returned by grep
set +e
CHANGES="$(git diff --name-only HEAD~1 | \
grep -E "workflows/.+-container-build.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go|docker/|\.dockerignore" | \
grep -v -E ".+_test.go|/.rhdh/")";
grep -E "workflows/.+-container-build.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go|docker/|\.dockerignore" | \
grep -v -E ".+_test.go|/.rhdh/")";
echo "Changed files for this commit:"
echo "=============================="
echo "$CHANGES"
Expand All @@ -77,23 +83,6 @@ jobs:
echo EOF
} >> "$GITHUB_ENV"
pr-build:
name: PR Publish
runs-on: ubuntu-latest
needs: [authorize, check-changes]
permissions:
contents: read
packages: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Setup Go
# run this stage only if there are changes that match the includes and not the excludes
if: ${{ env.CHANGES != '' }}
Expand Down
26 changes: 7 additions & 19 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,23 @@ on:
- 1.[0-9]+.x

jobs:
check-changes:
# check if the change for this PR necessitates a rebuild of containers
pr-validate:
name: PR Validate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: check-changes
# check changes in this commit for regex include and exclude matches; pipe to an env var
# note regexes are different for the PR check than for *-container-build.yaml

# check changes in this commit for regex include and exclude matches; pipe to an env var
- name: Check for changes to build
run: |
# don't fail if nothing returned by grep
set +e
CHANGES="$(git diff --name-only HEAD~1 | \
grep -E "workflows/pr.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go" | \
grep -v -E "/.rhdh/")";
grep -E "workflows/pr.yaml|Makefile|bundle/|config/|go.mod|go.sum|.+\.go" | \
grep -v -E "/.rhdh/")";
echo "Changed files for this commit:"
echo "=============================="
echo "$CHANGES"
Expand All @@ -51,16 +49,6 @@ jobs:
echo EOF
} >> "$GITHUB_ENV"
pr-validate:
name: PR Validate
runs-on: ubuntu-latest
needs: check-changes
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
Expand Down

0 comments on commit fc37ff4

Please sign in to comment.