Refresh community baselines #282
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Refresh community baselines | |
| on: | |
| schedule: | |
| # Keep scheduled check-runs sparse so Scorecard can still see CodeQL | |
| # check-runs on quiet commits when evaluating SAST coverage. | |
| - cron: '37 2 * * 1' | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: read | |
| jobs: | |
| refresh: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Call Edge Function | |
| env: | |
| FUNCTION_URL: ${{ secrets.SUPABASE_FUNCTION_URL }} | |
| ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} | |
| SECRET: ${{ secrets.REFRESH_SECRET }} | |
| run: | | |
| response=$(mktemp) | |
| trap 'rm -f "${response}"' EXIT | |
| curl_exit=0 | |
| http_code=$(curl -sS -X POST \ | |
| -o "${response}" \ | |
| -w "%{http_code}" \ | |
| "${FUNCTION_URL}/refresh-baselines" \ | |
| -H "Authorization: Bearer ${ANON_KEY}" \ | |
| -H "x-refresh-secret: ${SECRET}" \ | |
| -H "Content-Type: application/json") || curl_exit=$? | |
| if [ "${curl_exit}" -ne 0 ]; then | |
| echo "curl failed before producing an HTTP response (exit ${curl_exit})" | |
| exit 1 | |
| fi | |
| if ! [[ "${http_code}" =~ ^[0-9]+$ ]]; then | |
| echo "Invalid HTTP code: ${http_code:-<empty>}" | |
| exit 1 | |
| fi | |
| echo "HTTP ${http_code}" | |
| if [ "${http_code}" -ge 400 ]; then | |
| echo "Response body:" | |
| cat "${response}" | |
| echo | |
| exit 1 | |
| fi |