Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Sep 2, 2024
1 parent bb14fbb commit 33d3e3d
Showing 1 changed file with 5 additions and 41 deletions.
46 changes: 5 additions & 41 deletions .github/workflows/generate-api-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
generate-api-client:
name: Verify API Specs and Client
name: Verify API Specs and Client (add autocommit-openapi label to PR to auto-commit changes)
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -56,44 +56,8 @@ jobs:
exit 1
fi
- name: Remove autocommit-openapi label if job succeeds
if: ${{ success() && github.event.label.name == 'autocommit-openapi' }}
run: |
echo "Removing the autocommit-openapi label..."
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi
commit-changes:
name: Commit and Push API Client Changes
runs-on: ubuntu-latest
needs: generate-api-client
if: ${{ failure() && github.event.label.name == 'autocommit-openapi' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Install dependencies
run: npm install

- name: Generate API client
run: npm run generate:api

- name: Commit and push changes
if: ${{ failure() && github.event.label.name == 'autocommit-openapi' }}
run: |
echo "Committing and pushing changes..."
git config --global user.name "github-actions[bot]"
Expand All @@ -104,8 +68,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Remove the label
- name: Remove autocommit-openapi label
run: |
echo "Removing the autocommit-api label..."
echo "Removing the autocommit-openapi label..."
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi

0 comments on commit 33d3e3d

Please sign in to comment.