diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml new file mode 100644 index 0000000..e1eb9ef --- /dev/null +++ b/.github/workflows/openapi.yml @@ -0,0 +1,64 @@ +name: πŸ”€OpenAPI - Axios Client + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout ⬇️ + uses: actions/checkout@v4.2.2 + with: + show-progress: false + + - name: Cache Dependencies πŸ“¦ + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Copy Config File πŸ“„ + run: cp config.yaml.example config.yaml + + - name: Build πŸ› οΈ + run: cargo build --verbose + + - name: Generate OpenAPI Spec πŸ“œ + run: cargo run -- merge --url 'http://0.0.0.0:8080' --specs './docs/' --output './static/openapi.html' + + - name: Check if the schema was modified 🧐 + id: diff + run: | + diff=$(git status -su | grep static/openapi.yaml | wc -l) + echo "diff=$diff" >> $GITHUB_ENV + + - name: Commit changes πŸ“€ + if: ${{ env.diff != '0' && github.event_name == 'push' }} + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + git add . + git diff --quiet && git diff --staged --quiet || (git commit -m "chore: update openapi schema πŸ”„" && git push) + + - name: Dispatch event to Axios Client πŸš€ + uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: fis2425 + repo: apiclient + github_token: ${{ secrets.DISPATCH_TOKEN }} + workflow_file_name: generation.yml + ref: main + wait_workflow: false