Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions .github/workflows/prod-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Convert OpenAPI JSON -> YAML (swagger-cli)
run: |
set -euo pipefail
npm i -g @apidevtools/swagger-cli
npm i -g @apidevtools/swagger-cli@4
swagger-cli bundle openapi.json --type yaml --outfile openapi.yaml

- name: Checkout CodiveAPI repo
Expand All @@ -57,20 +57,38 @@ jobs:
set -euo pipefail
cp openapi.yaml "codiveapi/${TARGET_PATH}"

- name: Commit & push if changed
- name: Detect change (stage openapi)
id: regen
working-directory: codiveapi
run: |
set -euo pipefail
git config user.name "clokey-bot"
git config user.email "clokey[email protected]"
git config user.name "codive-bot"
git config user.email "codive[email protected]"

git add "${TARGET_PATH}"
ls -al "${TARGET_PATH}"

if git diff --cached --quiet; then
echo "No changes detected. Skipping commit."
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No changes detected. Skipping commit. (staged)."
exit 0
fi

echo "changed=true" >> "$GITHUB_OUTPUT"
echo "OpenAPI changed."

- name: Run generate script if changed
if: steps.regen.outputs.changed == 'true'
working-directory: codiveapi
run: |
set -euo pipefail
chmod +x ./regenerate-api.sh
./regenerate-api.sh
git add -A

git commit -m "chore: update openapi.yaml from production"
- name: Commit & Push Changes if changed
if: steps.regen.outputs.changed == 'true'
working-directory: codiveapi
run: |
set -euo pipefail
git commit -m "chore: update openapi.yaml and regenerate API"
git push origin "${CODIVEAPI_BRANCH}"