From 4f7ac8dcc851ea479b9cf512fd4c3983afbbbfde Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 16 Jun 2022 11:19:06 -0400 Subject: [PATCH 1/2] Copy/paste into workflows/ --- .../workflows/bump-api-schema-sha.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/bump-api-schema-sha.sh => .github/workflows/bump-api-schema-sha.yml (100%) diff --git a/scripts/bump-api-schema-sha.sh b/.github/workflows/bump-api-schema-sha.yml similarity index 100% rename from scripts/bump-api-schema-sha.sh rename to .github/workflows/bump-api-schema-sha.yml From 1840f610f90d10756b287c4e3cbfa77ab7cd96e9 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 16 Jun 2022 11:26:30 -0400 Subject: [PATCH 2/2] Convert bash script to workflow yaml --- .github/workflows/bump-api-schema-sha.yml | 35 ++++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/bump-api-schema-sha.yml b/.github/workflows/bump-api-schema-sha.yml index 6dcf9d8219681..73bf5c1f14e18 100644 --- a/.github/workflows/bump-api-schema-sha.yml +++ b/.github/workflows/bump-api-schema-sha.yml @@ -1,13 +1,26 @@ -#!/bin/bash +name: Bump API Schema SHA +on: -# This script is part of the API docs build process: -# -# https://develop.sentry.dev/api/public/#build-process + # This could be run manually, but general expectation is that this fires from GHA in + # getsentry/sentry-api-schema on changes there. See: + # + # https://develop.sentry.dev/api/public/#build-process -set -eu - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $SCRIPT_DIR/.. - -SENTRY_API_SCHEMA_SHA="$(curl -sSL 'https://api.github.com/repos/getsentry/sentry-api-schema/commits/main' | awk 'BEGIN { RS=",|:{\n"; FS="\""; } $2 == "sha" { print $4 }')" -sed -i -e 's|^const SENTRY_API_SCHEMA_SHA =.*$|const SENTRY_API_SCHEMA_SHA = "'$SENTRY_API_SCHEMA_SHA'"|g' src/gatsby/utils/resolveOpenAPI.ts + workflow_dispatch: +jobs: + release: + runs-on: ubuntu-latest + name: "Bump API Schema SHA" + steps: + - uses: actions/checkout@v2 + - name: "Bump API Schema SHA" + shell: bash + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + filepath="src/gatsby/utils/resolveOpenAPI.ts" + sha="$(curl -sSL 'https://api.github.com/repos/getsentry/sentry-api-schema/commits/main' | awk 'BEGIN { RS=",|:{\n"; FS="\""; } $2 == "sha" { print $4 }')" + sed -i -e 's|^const SENTRY_API_SCHEMA_SHA =.*$|const SENTRY_API_SCHEMA_SHA = "'$SHA'"|g' "$filepath" + git add "$filepath" + git commit -m "Bump API schema to $sha" + git push