diff --git a/.github/workflows/versions.yaml b/.github/workflows/versions.yaml index fa0def968861eb4815d378c127575df18567b086..4c001371bd6654e1f597079368307397c9c5aa74 100644 --- a/.github/workflows/versions.yaml +++ b/.github/workflows/versions.yaml @@ -3,8 +3,9 @@ name: Sync component versions on: schedule: - cron: '18 8 * * *' + jobs: - labeler: + versions: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -12,5 +13,5 @@ jobs: - uses: romoh/dependencies-autoupdate@v1.1 with: token: ${{ secrets.GITHUB_TOKEN }} - update-command: './scripts/generate-versions.sh > jsonnet/kube-prometheus/versions.json' - on-changes-command: 'make --always-make generate' + update-command: "'scripts/generate-versions.sh $token > jsonnet/kube-prometheus/versions.json'" + on-changes-command: "'make --always-make generate'" diff --git a/scripts/generate-versions.sh b/scripts/generate-versions.sh index 8505f6d862efa60b62d2c63da75c8a3cf4c86ea9..4db472a1a8f37ca20e7c93ce74d4a92776ac9549 100755 --- a/scripts/generate-versions.sh +++ b/scripts/generate-versions.sh @@ -1,20 +1,23 @@ #!/bin/bash +set -euo pipefail + get_latest_version() { - curl --retry 5 --silent -H "Authorization: token $token" "https://api.github.com/repos/${1}/releases/latest" | jq '.tag_name' | tr -d '"v' + echo >&2 "Checking release version for ${1}" + curl --retry 5 --silent --fail -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/${1}/releases/latest" | jq '.tag_name' | tr -d '"v' } -# token can be passed as `GITHUB_TOKEN` or `token` variable -token=${token:-${GITHUB_TOKEN}} +# token can be passed as `GITHUB_TOKEN` variable or passed as first argument +GITHUB_TOKEN=${GITHUB_TOKEN:-${1}} -if [ -z "$token" ]; then - echo "GITHUB_TOKEN not set. Exiting" +if [ -z "$GITHUB_TOKEN" ]; then + echo >&2 "GITHUB_TOKEN not set. Exiting" exit 1 fi cat <<-EOF { - "alertmanager": "$(get_latest_version "prometheus/alertmanager")" + "alertmanager": "$(get_latest_version "prometheus/alertmanager")", "blackboxExporter": "$(get_latest_version "prometheus/blackbox_exporter")", "grafana": "$(get_latest_version "grafana/grafana")", "nodeExporter": "$(get_latest_version "prometheus/node_exporter")",