-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
60 lines (52 loc) · 2.16 KB
/
bump-api-schema-sha.yml
File metadata and controls
60 lines (52 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Bump API Schema SHA
on:
# This could be run manually, but the 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
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
name: 'Bump API Schema SHA'
steps:
- name: Get auth token
id: token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.SENTRY_API_SCHEMA_UPDATER_APP_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_API_SCHEMA_UPDATER_PRIVATE_KEY }}
owner: getsentry
repositories: |
sentry-docs
sentry-api-schema
- uses: actions/checkout@v6 # v6
with:
token: ${{ steps.token.outputs.token }}
- name: 'Bump API Schema SHA'
shell: bash
env:
# An elevated token is necessary because with plain github.token
# GitHub does not recursively call workflows, which means CI does not
# kick off for the PR we're about to create.
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
run: |
set -euo pipefail
git config user.email "271575301+sentry-api-schema-updater[bot]@users.noreply.github.com"
git config user.name "sentry-api-schema-updater[bot]"
filepath="src/build/resolveOpenAPI.ts"
sha="$(curl -sSl -H 'Accept: application/vnd.github.VERSION.sha' 'https://api.github.com/repos/getsentry/sentry-api-schema/commits/main')"
echo "Latest commit to 'getsentry/sentry-api-schema' is $sha"
sed -i -e "s|^const SENTRY_API_SCHEMA_SHA =.*$|const SENTRY_API_SCHEMA_SHA = '$sha';|g" "$filepath"
echo "Updated $filepath"
if git diff --quiet "$filepath"; then
echo "No changes to $filepath, skipping."
exit 0
fi
branch="bot/bump-api-schema-to-${sha:0:8}"
git checkout -b "$branch"
git add "$filepath"
git commit -m "Bump API schema to ${sha:0:8}"
git push --set-upstream origin "$branch"
gh pr create --fill
gh pr merge --squash --admin -d