Skip to content

Commit

Permalink
Refactor before merge
Browse files Browse the repository at this point in the history
* SHA256 string is now 7 chars long instead of 8
* quay namespace is now hardcoded
* prevent consecutive hyphens or underscore chars in the file path.

Signed-off-by: Jon Disnard <jdisnard@redhat.com>
  • Loading branch information
parasense committed May 5, 2022
1 parent 0b18f26 commit af55096
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/tekton_bundle_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on: # yamllint disable-line rule:truthy
workflow_dispatch:
env:
IMAGE_REGISTRY: quay.io
IMAGE_NAMESPACE: ${{ secrets.QUAY_NAMESPACE }}
IMAGE_NAMESPACE: hacbs-release
REGISTRY_USER: ${{ secrets.QUAY_ROBOT_USER }}
REGISTRY_PASSWORD: ${{ secrets.QUAY_ROBOT_TOKEN }}
API_TOKEN: ${{ secrets.QUAY_API_TOKEN }}
Expand Down Expand Up @@ -47,23 +47,33 @@ jobs:
while read file
do
# Only match yaml files in bundle dirs within definitions dir.
if [[ ${file} =~ ^("./")?"definitions/"[a-z,A-Z,0-9,_-]+"/"[a-z,A-Z,0-9,_-]+".yaml"$ ]]
if [[ $file =~ .*[-,_]{2,} ]]
then
printf 'MATCH: %s\n' "$file"
bundle_dirs["${file%/*}"]+="${file##*/} " # hash the bundle dir
printf 'NO consecutive hyphen or underscores allowed: %s\n' "$file"
elif [[ ${file} =~ ^("./")?"definitions/"[a-z,A-Z,0-9,_-]+"/"[a-z,A-Z,0-9,_-]+".yaml"$ ]]
then
printf 'MATCHED: %s\n' "$file"
bundle_dirs["${file%/*}"]="" # hash the bundle dir
else
printf 'NO MATCH: %s\n' "$file"
fi
done < <(git diff-tree --no-commit-id --name-only -r ${{ github.sha }})
# EO gathering changed definitions
printf 'bundle_dirs: %s\n' "${!bundle_dirs[@]}"
# Main loop
printf 'Pushing any new/modified bundle definitions.\n'
for BUNDLE_DIR in "${!bundle_dirs[@]}"
do
if [[ ! -d "$BUNDLE_DIR" ]]
then
printf 'Skipping non-existing bundle-path: %s\n' "$BUNDLE_DIR"
continue
fi
BUNDLE_FILES=()
BUNDLE_NAME=${BUNDLE_DIR##*/}
printf '* Bundle_dir: %s\n' $BUNDLE_DIR
printf '* Bundle name: %s\n' $BUNDLE_NAME
BUNDLE_FILES=()
for file in $BUNDLE_DIR/*.yaml
do
[[ -e "$file" ]] || continue
Expand Down Expand Up @@ -108,8 +118,8 @@ jobs:
--data "$new_repo_string"
fi
printf 'Pushing image to repo: %s:%s\n' "$image_string" "${GITHUB_SHA:0:8}"
tkn bundle push ${bundle_files_args} "${image_string}:${GITHUB_SHA:0:8}"
printf 'Pushing image to repo: %s:%s\n' "$image_string" "${GITHUB_SHA:0:7}"
tkn bundle push ${bundle_files_args} "${image_string}:${GITHUB_SHA:0:7}"
printf 'Pushing image to repo: %s:%s\n' "$image_string" "${{ github.ref_name }}"
tkn bundle push ${bundle_files_args} "${image_string}:${{ github.ref_name }}"
Expand Down

0 comments on commit af55096

Please sign in to comment.