Skip to content

Commit

Permalink
Add update all file and update script (#13)
Browse files Browse the repository at this point in the history
* Add update all file and update script

* Update action

* Update UPDATE_ALL

---------

Co-authored-by: Barb Cutler <[email protected]>
  • Loading branch information
cjreed121 and bmcutler authored Dec 1, 2023
1 parent a37f9e1 commit 760bff8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set Matrix
id: set-matrix
run: |
echo "matrix=$(python3 bin/generate_matrix.py submittyrpi false ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT
echo "matrix=$(python3 bin/generate_matrix.py submittyrpi ${{ github.event.before }} ${{ github.event.after }})" >> $GITHUB_OUTPUT
- name: List Matrix
run: |
echo ${{ steps.set-matrix.outputs.matrix }}
Expand Down
7 changes: 7 additions & 0 deletions UPDATE_ALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Modifying this file will result in a build and push of all Dockerfiles

Append a message below with the date and why all containers should be rebuilt

-----------------------------------------------------------------------------


21 changes: 11 additions & 10 deletions bin/generate_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import sys
from pathlib import Path

if len(sys.argv) > 5:
if len(sys.argv) > 4:
print("Too many arguments!", file=sys.stderr)
exit(1)
elif len(sys.argv) < 3:
elif len(sys.argv) < 2:
print("Not enough arguments!", file=sys.argv)
exit(1)

Expand All @@ -16,18 +16,19 @@
exit(1)

username = sys.argv[1]
build_all = sys.argv[2]

to_build = []

if build_all == "false":
hash_before = sys.argv[3]
hash_after = sys.argv[4]
hash_before = sys.argv[2]
hash_after = sys.argv[3]

# Get list of all changed files between 2 commits
output = subprocess.check_output(["git", "--no-pager", "diff", "--name-only", "--diff-filter=d", hash_before, hash_after])
paths_updated = output.decode("utf-8").splitlines()
# Get list of all changed files between 2 commits
output = subprocess.check_output(["git", "--no-pager", "diff", "--name-only", "--diff-filter=d", hash_before, hash_after])
paths_updated = output.decode("utf-8").splitlines()

build_all = "UPDATE_ALL" in paths_updated

if not build_all:
image_set = set()
image_tag_set = set()

Expand Down Expand Up @@ -89,7 +90,7 @@
}
)

elif build_all == "true":
else:
images = os.listdir("dockerfiles")
for image in images:
path = Path("dockerfiles") / image
Expand Down

0 comments on commit 760bff8

Please sign in to comment.