Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 57d96ca

Browse files
authored
ci: add script to check modules on registry.coder.com (#340)
Added a script + corresponding GitHub action to check active modules on registry.coder.com
1 parent f5ab799 commit 57d96ca

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.github/scripts/check.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -o pipefail
3+
REGISTRY_BASE_URL="${REGISTRY_BASE_URL:-https://registry.coder.com}"
4+
set -u
5+
6+
if [[ -n "${VERBOSE:-}" ]]; then
7+
set -x
8+
fi
9+
10+
status=0
11+
declare -a modules=()
12+
declare -a failures=()
13+
for path in $(find . -not -path '*/.*' -type f -name main.tf -maxdepth 2 | cut -d '/' -f 2 | sort -u); do
14+
modules+=("${path}")
15+
done
16+
echo "Checking modules: ${modules[*]}"
17+
for module in "${modules[@]}"; do
18+
# Trim leading/trailing whitespace from module name
19+
module=$(echo "${module}" | xargs)
20+
url="${REGISTRY_BASE_URL}/modules/${module}"
21+
printf "=== Check module %s at %s\n" "${module}" "${url}"
22+
status_code=$(curl --output /dev/null --head --silent --fail --location "${url}" --retry 3 --write-out "%{http_code}")
23+
# shellcheck disable=SC2181
24+
if (( status_code != 200 )); then
25+
printf "==> FAIL(%s)\n" "${status_code}"
26+
status=1
27+
failures+=("${module}")
28+
else
29+
printf "==> OK(%s)\n" "${status_code}"
30+
fi
31+
done
32+
33+
if (( status != 0 )); then
34+
echo "The following modules appear to have issues: ${failures[*]}"
35+
fi
36+
exit "${status}"

.github/workflows/check.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Check modules on registry.coder.com
2+
3+
on:
4+
schedule:
5+
- cron: "*/13 * * * *" # Runs every 13th minute
6+
workflow_dispatch: # Allows manual triggering of the workflow if needed
7+
8+
jobs:
9+
run-script:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Run check.sh
17+
run: |
18+
./.github/scripts/check.sh

0 commit comments

Comments
 (0)