-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[COR-175] Move "file changed?" logic into a github action #82
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: 'Find changed directories' | ||
description: 'Finds directories containing a specific filename in the root of that directory, filtering out directories that are unchanged relative to a given branch name' | ||
inputs: | ||
contains_the_file: | ||
description: 'Look for directories with this file in the root of that directory. For example, Dockerfile or Cargo.toml' | ||
required: true | ||
changed_relative_to_branch: | ||
description: 'The branch on the origin to compare with to determine if this directory has changed. For example "main".' | ||
required: true | ||
outputs: | ||
build_matrix: | ||
description: "Input this output to your matrix build in a following job, like this 'fromJson(needs.find_directories.outputs.build_matrix)'" | ||
value: ${{ steps.find_directories.outputs.build_matrix }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Find directories with Dockerfiles | ||
shell: bash | ||
id: find_directories | ||
run: | | ||
set -xe | ||
git fetch origin ${{ inputs.changed_relative_to_branch }} || true | ||
# Get directories with a Dockerfile that have not changed | ||
# relative to the branch we are pulling into | ||
directories=$( | ||
find . -name ${{ inputs.contains_the_file }} -not -path "*/target/*" -exec dirname {} \; | while read dir; do | ||
# This will check if the directory has changed relative to the branch we are PRing | ||
# into, and if it's not a PR, in the case of main or release/**, then it will | ||
# build all docker directories | ||
if git diff --quiet HEAD origin/${{ inputs.changed_relative_to_branch }} -- "$dir"; then | ||
echo "" | ||
else | ||
echo "$dir" | ||
fi | ||
done) | ||
# Format directories into a build matrix | ||
matrix_include=$(echo "${directories}" | awk 'NF{print $NF};' | while read dir; do dir_without_dot=${dir#./}; echo "{\"path\": \"$dir\", \"name\": \"$dir_without_dot\"}"; done | jq -scM '{"include": .}') | ||
echo "${matrix_include}" | ||
echo "build_matrix=${matrix_include}" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- release** | ||
- 'release/[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- release** | ||
- 'release/[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- release** | ||
- 'release/[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- release** | ||
- 'release/[0-9]+.[0-9]+' | ||
|
||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
- release** | ||
- 'release/[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
lint: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR just moves this script into a github action.