ci: add script to check modules on registry.coder.com

pull/340/head
Cian Johnston 6 months ago
parent f5ab7995d1
commit 2ffe93ad47

@ -0,0 +1,18 @@
name: Check modules on registry.coder.com
on:
schedule:
- cron: "23 * * * *" # Runs at 23 minutes past the hour.
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: |
./check.sh

@ -0,0 +1,37 @@
#!/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=()
modules+=("doesnotexist")
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}"
Loading…
Cancel
Save