Skip to content

Commit d7aacc2

Browse files
authored
Merge pull request #117 from blues/alex-add-update-schema-hook
feat: add GitHub Actions workflow to update Notecard Fluent API from …
2 parents 38ee173 + 72ee075 commit d7aacc2

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Update Notecard Fluent API from upstream schema
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
upstream_commit:
6+
description: 'Upstream commit that triggered this update'
7+
required: false
8+
type: string
9+
10+
jobs:
11+
update-notecard-api:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Python 3.12
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.12
20+
21+
- name: Install pipenv
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install pipenv
25+
26+
- name: Fetch schemas and generate Fluent API
27+
run: |
28+
echo "Updating from upstream commit: ${{ inputs.upstream_commit }}"
29+
pipenv run python scripts/generate_apis.py --output-dir notecard
30+
31+
- name: Check for changes
32+
id: changes
33+
run: |
34+
if git diff --quiet; then
35+
echo "has_changes=false" >> $GITHUB_OUTPUT
36+
else
37+
echo "has_changes=true" >> $GITHUB_OUTPUT
38+
fi
39+
40+
- name: Create Pull Request with GitHub CLI
41+
if: steps.changes.outputs.has_changes == 'true'
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
git config --global user.name "github-actions[bot]"
46+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
47+
48+
BRANCH_NAME="update-notecard-api-${{ github.run_number }}"
49+
git checkout -b $BRANCH_NAME
50+
51+
git add .
52+
git commit -m "Update Notecard API from upstream schema changes (${{ inputs.upstream_commit || 'forced' }})"
53+
54+
git push origin $BRANCH_NAME
55+
56+
gh pr create \
57+
--title "Auto-update: API changes from upstream" \
58+
--body "Automated PR to update API based on upstream schema changes (${{ inputs.upstream_commit || 'forced' }})" \
59+
--base main \
60+
--head $BRANCH_NAME

0 commit comments

Comments
 (0)