-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from rse-ops/shorten-workflows
testing shortening PR workflow
- Loading branch information
Showing
8 changed files
with
222 additions
and
101 deletions.
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,21 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
basedir=$(dirname ${result_name}) | ||
printf "Base directory is ${basedir}\n" | ||
dockerfile=$(basename ${result_name}) | ||
printf "Dockerfile basename is ${dockerfile}\n" | ||
tag=$(basename ${basedir}) | ||
printf "Tag is ${tag}\n" | ||
container=$(basename $(dirname $basedir)) | ||
printf "Container is ${container}\n" | ||
cat ${result_name} | ||
cd $basedir | ||
container_name=ghcr.io/rse-ops/${container}:${tag} | ||
docker pull ${container_name} || echo "Container $container_name does not exist yet" | ||
docker build -f ${dockerfile} -t ${container_name} . | ||
echo ::set-output name=container_uri::${container_name} | ||
echo ::set-output name=uri::ghcr.io/rse-ops/${container} | ||
echo ::set-output name=tag::${tag} | ||
echo ::set-output name=dockerfile_dir::${basedir} |
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,13 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo $PWD | ||
basedir=$(dirname $filename) | ||
printf "Base directory is ${basedir}\n" | ||
# Get relative path to PWD and generate dashed name from it | ||
cd $basedir | ||
echo "${prefix} -t ${container} ." | ||
${prefix} -t ${container} . | ||
echo ::set-output name=uri::${container} | ||
echo ::set-output name=dockerfile_dir::${basedir} |
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,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [[ "${result}" == "" ]]; then | ||
result="[]" | ||
fi | ||
|
||
if [[ "${result_scheduled}" == "" ]]; then | ||
result_scheduled="[]" | ||
fi | ||
|
||
# Combine results into new output | ||
result=$(python -c "import json; print(json.loads('${result}') + json.loads('${result_scheduled}'))") | ||
if [[ "${result}" == "[]" ]]; then | ||
printf "The matrix is empty, will not trigger next workflow.\n" | ||
echo "::set-output name=empty_matrix::true" | ||
else | ||
printf "The matrix is not empty, and we should continue on to the next workflow.\n" | ||
echo "::set-output name=empty_matrix::false" | ||
fi | ||
echo ${result} | ||
|
||
# set for both workflows that use it | ||
echo "::set-output name=dockerfilelist_matrix::${result}" | ||
echo "::set-output name=dockerbuild_matrix::${result}" |
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,28 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
printf "GitHub Actor: ${GITHUB_ACTOR}\n" | ||
git config user.name "github-actions" | ||
git config user.email "github-actions@users.noreply.github.com" | ||
git fetch || printf "fetch did not work\n" | ||
git checkout main || printf "Already on main!\n" | ||
|
||
# Add all results! | ||
for row in $(echo "${result}" | jq -r '.[] | @base64'); do | ||
_jq() { | ||
echo ${row} | base64 --decode | jq -r ${1};} | ||
git add $(_jq '.name') | ||
done | ||
|
||
set +e | ||
git status | grep modified | ||
if [ $? -eq 0 ]; then | ||
set -e | ||
printf "Changes\n" | ||
git commit -a -m "Automated push to update ${result_name} $(date '+%Y-%m-%d')" || exit 0 | ||
git push origin main | ||
else | ||
set -e | ||
printf "No changes\n" | ||
fi |
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,27 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
parsed="" | ||
for file in ${changed_files}; do | ||
filename=$(basename ${file}) | ||
|
||
# We are going to have paths inside/outside container and need relative | ||
if [[ "$filename" == "uptodate.yaml" ]]; then | ||
parsed="${parsed} ${file}" | ||
fi | ||
# If we find a Dockerfile, change to uptodate.yaml if it exists | ||
if [[ "$filename" == "Dockerfile" ]]; then | ||
dir=$(dirname ${file}) | ||
uptodate_yaml=${dir}/uptodate.yaml | ||
if [[ -e "${uptodate_yaml}" ]]; then | ||
parsed="${parsed} ${uptodate_yaml}" | ||
fi | ||
fi | ||
done | ||
echo ${parsed} | ||
|
||
# No parsed results will build ALL | ||
if [[ "${parsed}" == "" ]]; then | ||
parsed="/does/not/exist/pathy" | ||
fi | ||
echo "::set-output name=parsed_files::${parsed}" |
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,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "Original path is $filename" | ||
relative=$(echo ${filename/\/github\/workspace\//}) | ||
echo "Relative path is $relative" | ||
echo "::set-output name=relative_path::${relative}" |
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
Oops, something went wrong.