-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add update-public-api-reference-action
- Loading branch information
Showing
4 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# update-api-reference.yml | ||
name: Update Public API Reference | ||
|
||
on: | ||
schedule: | ||
# Run at midnight every Saturday | ||
- cron: '0 0 * * 6' | ||
workflow_dispatch: # Manual trigger | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
update-api-reference: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout GaloyMoney/galoy repo | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: 'GaloyMoney/galoy' | ||
path: 'galoy' | ||
|
||
- name: Get current commit hash | ||
run: echo "CURRENT_COMMIT_HASH=$(git -C galoy rev-parse HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Hash current schema.graphql | ||
run: | | ||
echo "CURRENT_HASH=$(sha256sum galoy/core/api/src/graphql/public/schema.graphql | awk '{ print $1 }')" >> $GITHUB_ENV | ||
- name: Checkout GaloyMoney/galoy to a week ago | ||
run: | | ||
echo "WEEK_OLD_COMMIT=$(git -C galoy rev-list -n 1 --before="1 week ago" main)"" >> $GITHUB_ENV | ||
echo "Checking out to commit: ${{ env.WEEK_OLD_COMMIT }}" | ||
git -C galoy checkout ${{ env.WEEK_OLD_COMMIT }} | ||
- name: Hash the week old schema.graphql | ||
id: week_old_hash | ||
run: echo "WEEK_OLD_HASH=$(sha256sum galoy/core/api/src/graphql/public/schema.graphql | awk '{ print $1 }')" >> $GITHUB_ENV | ||
|
||
- name: Check if hashes are the same | ||
if: env.CURRENT_HASH == env.WEEK_OLD_HASH | ||
run: | | ||
echo "There were no changes to the public API reference in the last week." | ||
- name: Checkout dev.blink.sv repo | ||
if: env.CURRENT_HASH != env.WEEK_OLD_HASH | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: 'GaloyMoney/dev.blink.sv' | ||
path: 'dev.blink.sv' | ||
|
||
- name: Build and update the API reference | ||
if: env.CURRENT_HASH != env.WEEK_OLD_HASH | ||
run: | | ||
cd dev.blink.sv | ||
# Build the API reference | ||
./scripts/generate-galoy-api-reference.sh | ||
# Commit and push changes | ||
git config --local user.name 'github-actions[bot]' | ||
git config --local user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add . | ||
git commit -m "public api reference update to ${{ env.CURRENT_COMMIT_HASH }}" | ||
git push | ||
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# deps | ||
if ! git --version; then sudo apt-get install -y git; fi | ||
if ! node --version; then sudo apt-get install -y nodejs; fi | ||
if ! yarn --version; then sudo apt-get install -y yarn; fi | ||
if ! npx spectaql --version; then yarn add spectaql --non-interactive; fi | ||
|
||
mkdir -p .temp | ||
cd .temp || exit 1 | ||
|
||
# checkout galoy | ||
if [ ! -d "galoy" ]; then | ||
git clone https://github.com/GaloyMoney/galoy | ||
fi | ||
cd galoy || exit 1 | ||
|
||
# build admin api reference | ||
npx spectaql ./../../scripts/spectaql/spectaql-config-admin-api.yml \ | ||
-t ./../../static -f admin-api-reference.html || exit 1 | ||
|
||
# set dark mode | ||
sed -i 's/spectaql.min.css/spectaql.dark.css/' ./../../static/admin-api-reference.html |
This file contains 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