Skip to content

Commit

Permalink
more minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bauer committed Mar 26, 2024
1 parent c6143e9 commit fa71f67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
3 changes: 0 additions & 3 deletions misc/Auto-DevOps.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Create ARC JSON:
quality_report_generator:
stage: quality_report_generator
rules:
- if: $CI_COMMIT_REF_NAME != "cqc"
- exists:
- .arc/validation_packages.yml
script:
Expand Down Expand Up @@ -64,8 +63,6 @@ quality_report_generator:
- ret=$?
- mkdir -p "${CI_COMMIT_BRANCH}"
- mv ".arc-validate-results/${p}" "${CI_COMMIT_BRANCH}/${p}${v:+@$v}"
- ls -la "$CI_COMMIT_BRANCH"/* || true
- ls -la "$CI_COMMIT_BRANCH"/*/* || true
- exit $ret
artifacts:
when: always
Expand Down
30 changes: 15 additions & 15 deletions misc/datahub-hooks.bash
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,37 @@ if [ ! -e "$datahub_secrets" ]; then
exit 1
fi

. "$datahub_secrets"

# setup logging
declare -rg log_file="/var/log/datahub/${0##*/}.$$.log"
if [ "$HOOK_DEBUG" = "1" ]; then
exec &> "$log_file"
set -x
fi

# Get the event from stdin
json="$(cat -)"
echo "EVENT: $(jq . <<< "$json")"

event_type="$(jq -r '.object_kind // empty' <<< "$json")"
event_name="$(jq -r '.event_name // empty' <<< "$json")"
event_ref="$(jq -r '.object_attributes.ref // empty' <<< "$json")"
event_id="$(jq -r '.object_attributes.id // empty' <<< "$json")"

if { [ -n "$event_type" ] && [ "$event_type" != "pipeline" ] && [ "$event_type" != "push" ]; } \
|| { [ -n "$event_name" ] && [ "$event_name" != "project_create" ] ; } \
|| { [ -n "$event_name" ] && [ "$event_name" != "push" ] ; }; then
if { [ -n "$event_type" ] && [ "$event_type" != "pipeline" ]; } \
|| { [ -n "$event_name" ] && [ "$event_name" != "project_create" ] && [ "$event_name" != "push" ]; }; then
echo "Ignoring $event_type | $event_name"
exit 0
fi

# for event_types the project id is in .project.id
## Read the configuration file
. "$datahub_secrets"

# setup logging
declare -rg log_file="/var/log/datahub/${0##*/}.$$.log"
if [ "$HOOK_DEBUG" = "1" ]; then
exec &> "$log_file"
set -x
fi

project_id="$(jq -r '.project.id // empty' <<< "$json")"
# for event_name the project id is in .project_id
# for the event "project_create" the project id is in .project_id
[ -z "$project_id" ] && project_id="$(jq -r '.project_id // empty' <<< "$json")"

project_name="$(jq -r '.project.path_with_namespace // empty' <<< "$json")"
# for the event "project_create" the project name is in: .path_with_namespace
[ -z "$project_name" ] && project_name="$(jq -r '.path_with_namespace // empty' <<< "$json")"

if [ -z "$project_id" ]; then
echo "Could not get the project id."
Expand Down

0 comments on commit fa71f67

Please sign in to comment.