ci: add script to check modules on registry.coder.com (#340)
Added a script + corresponding GitHub action to check active modules on registry.coder.compull/341/head
parent
f5ab7995d1
commit
57d96ca27f
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o pipefail
|
||||
REGISTRY_BASE_URL="${REGISTRY_BASE_URL:-https://registry.coder.com}"
|
||||
set -u
|
||||
|
||||
if [[ -n "${VERBOSE:-}" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
status=0
|
||||
declare -a modules=()
|
||||
declare -a failures=()
|
||||
for path in $(find . -not -path '*/.*' -type f -name main.tf -maxdepth 2 | cut -d '/' -f 2 | sort -u); do
|
||||
modules+=("${path}")
|
||||
done
|
||||
echo "Checking modules: ${modules[*]}"
|
||||
for module in "${modules[@]}"; do
|
||||
# Trim leading/trailing whitespace from module name
|
||||
module=$(echo "${module}" | xargs)
|
||||
url="${REGISTRY_BASE_URL}/modules/${module}"
|
||||
printf "=== Check module %s at %s\n" "${module}" "${url}"
|
||||
status_code=$(curl --output /dev/null --head --silent --fail --location "${url}" --retry 3 --write-out "%{http_code}")
|
||||
# shellcheck disable=SC2181
|
||||
if (( status_code != 200 )); then
|
||||
printf "==> FAIL(%s)\n" "${status_code}"
|
||||
status=1
|
||||
failures+=("${module}")
|
||||
else
|
||||
printf "==> OK(%s)\n" "${status_code}"
|
||||
fi
|
||||
done
|
||||
|
||||
if (( status != 0 )); then
|
||||
echo "The following modules appear to have issues: ${failures[*]}"
|
||||
fi
|
||||
exit "${status}"
|
@ -0,0 +1,18 @@
|
||||
name: Check modules on registry.coder.com
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/13 * * * *" # Runs every 13th minute
|
||||
workflow_dispatch: # Allows manual triggering of the workflow if needed
|
||||
|
||||
jobs:
|
||||
run-script:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run check.sh
|
||||
run: |
|
||||
./.github/scripts/check.sh
|
Loading…
Reference in New Issue