EIN-4526: Prepare for search & statistics endpoints #62
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
name: Build OpenAPI and commit changes | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'typespec/**' | |
jobs: | |
build-and-commit: | |
if: ${{ github.actor != 'einnsyn-codegen[bot]' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch app token | |
uses: tibdex/github-app-token@v2.1.0 | |
id: gh-api-token | |
with: | |
app_id: ${{ secrets.EIN_CODEGEN_APP_ID }} | |
private_key: ${{ secrets.EIN_CODEGEN_APP_PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: oven-sh/setup-bun@v2 | |
- run: bun install | |
- run: bun run build | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ steps.gh-api-token.outputs.token }} | |
FILE_TO_COMMIT: "openapi/einnsyn.openapi.yml" | |
run: | | |
git add . | |
if git diff --cached --quiet; then | |
echo "No changes to commit." | |
else | |
export BRANCH=${{ github.head_ref }} | |
export SHA=$( git rev-parse "$BRANCH:$FILE_TO_COMMIT" ) | |
echo "Branch: $BRANCH" | |
echo "SHA: $SHA" | |
git branch --list | |
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ | |
--field message="Autogenerate OpenAPI spec from TypeSpec" \ | |
--field content=@<( base64 -i $FILE_TO_COMMIT ) \ | |
--field branch="$BRANCH" \ | |
--field sha="$SHA" | |
fi |