From ebef4e02ef7ccbbf0ce26e64f462ca4f5aedaa54 Mon Sep 17 00:00:00 2001 From: paulfantom <pawel@krupa.net.pl> Date: Thu, 25 Feb 2021 15:41:56 +0100 Subject: [PATCH] fix version updating CI job --- .github/workflows/versions.yaml | 7 ++++--- scripts/generate-versions.sh | 15 +++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/versions.yaml b/.github/workflows/versions.yaml index fa0def96..4c001371 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 8505f6d8..4db472a1 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")", -- GitLab