From 3dab7289fd9dcf111a988fe0453333ddc53f5f58 Mon Sep 17 00:00:00 2001 From: Deep Singhvi Date: Mon, 21 Apr 2025 17:06:51 -0700 Subject: [PATCH] chore: update openapi every 30 min --- .github/workflows/update-openapi.yml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/update-openapi.yml b/.github/workflows/update-openapi.yml index 09309be5c..3c21edaa4 100644 --- a/.github/workflows/update-openapi.yml +++ b/.github/workflows/update-openapi.yml @@ -2,21 +2,24 @@ name: Update OpenAPI Specification on: workflow_dispatch: + schedule: + - cron: "*/30 * * * *" + jobs: update-openapi: runs-on: ubuntu-latest - permissions: + permissions: contents: write pull-requests: write steps: - name: Checkout repository uses: actions/checkout@v4 - + - name: Fetch OpenAPI specification run: | npm install -g fern-api fern api update - + - name: Check for changes id: check_changes run: | @@ -27,7 +30,7 @@ jobs: echo "Changes detected in OpenAPI specification" echo "changes_detected=true" >> $GITHUB_OUTPUT fi - + - name: Setup GitHub CLI id: setup_cli if: steps.check_changes.outputs.changes_detected == 'true' @@ -35,20 +38,20 @@ jobs: # Create timestamp for unique branch name TIMESTAMP=$(date +%Y%m%d%H%M%S) BRANCH_NAME="update-openapi-spec-${TIMESTAMP}" - + # Setup branch for changes git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" - + # Create new branch with timestamp git checkout -b $BRANCH_NAME git add ./fern/apis/api/openapi.json git commit -m "chore: update OpenAPI specification" git push -u origin $BRANCH_NAME - + # Store branch name for PR creation echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT - + - name: Create Pull Request with GitHub CLI if: steps.check_changes.outputs.changes_detected == 'true' run: | @@ -63,13 +66,13 @@ jobs: - Generated at: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - name: PR Result if: steps.check_changes.outputs.changes_detected == 'true' run: | echo "Pull request created successfully!" - + - name: No Changes Result if: steps.check_changes.outputs.changes_detected == 'false' run: | - echo "No changes detected in OpenAPI specification. No PR created." \ No newline at end of file + echo "No changes detected in OpenAPI specification. No PR created."