From 8c6dcc0da36170b173e4cc8d4cff56591eced3ea Mon Sep 17 00:00:00 2001 From: adrrf Date: Thu, 26 Dec 2024 17:12:10 +0100 Subject: [PATCH 1/2] ci: apiclient dispatch --- .github/workflows/openapi.yml | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/openapi.yml diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml new file mode 100644 index 0000000..1b3877d --- /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: main + wait_workflow: false From d8c1434585d3ae8a7b861ddfe71a1b432e93590e Mon Sep 17 00:00:00 2001 From: adrrf Date: Sat, 28 Dec 2024 17:57:40 +0100 Subject: [PATCH 2/2] fix: deprecated set-output --- .github/workflows/openapi.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml index 1b3877d..e1eb9ef 100644 --- a/.github/workflows/openapi.yml +++ b/.github/workflows/openapi.yml @@ -41,15 +41,17 @@ jobs: - name: Check if the schema was modified 🧐 id: diff - run: echo '::set-output name=diff::$(git status -su | grep static/openapi.yaml | wc -l)' + run: | + diff=$(git status -su | grep static/openapi.yaml | wc -l) + echo "diff=$diff" >> $GITHUB_ENV - name: Commit changes πŸ“€ - if: ${{ steps.diff.outputs.diff != '0' && github.event_name == 'push' }} + 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 shemaπŸ”„" && git push) + 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