diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml new file mode 100644 index 0000000..878e4ac --- /dev/null +++ b/.github/workflows/openapi.yml @@ -0,0 +1,62 @@ +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: echo '::set-output name=diff::$(git status -su | grep static/openapi.yaml | wc -l)' + + - name: Commit changes ๐Ÿ“ค + if: ${{ steps.diff.outputs.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 shema๐Ÿ”„" && 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: ${{ github.ref_name }} + wait_workflow: false