traq 0.1.5

⚠️ Community Driven ⚠️ traQ v3 API
Documentation
name: Regenerate

on:
  workflow_dispatch:

concurrency:
  group: openapi-regenerate

jobs:
  check-diff:
    name: check diff
    runs-on: ubuntu-latest
    outputs:
      has_diff: ${{ steps.check-diff.outputs.has_diff }}
    steps:
      - name: checkout
        uses: actions/checkout@v3
      - name: restore diff cache
        uses: actions/cache@v3
        with:
          path: ./tmp
          key: diff
      - name: Check diff
        id: check-diff
        run: |
          touch tmp
          git clone https://github.com/traPtitech/traQ
          cd traQ
          git log --oneline -1 -- 'docs/v3-api.yaml' | sed -e "s/ .*$//" > ../tmp_new
          cd ..
          rm -rf traQ
          cat tmp_new
          if diff tmp tmp_new > /dev/null; then
            echo "has_diff=false" >> "$GITHUB_OUTPUT"
          else
            echo "has_diff=true" >> "$GITHUB_OUTPUT"
          fi
          mv tmp_new tmp

  regenerate:
    name: regenerate
    runs-on: ubuntu-latest
    needs: check-diff
    if: needs.check-diff.outputs.has_diff == 'true'
    permissions:
      contents: write
      pull-requests: write
    steps:
      - name: checkout
        uses: actions/checkout@v3
      - name: setup java
        uses: actions/setup-java@v3
        with:
          distribution: 'adopt'
          java-version: '17'
      - name: install openapi-generator
        run: |
          OPENAPI_GENERATOR_VERSION=`cat .openapi-generator/VERSION`
          wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_GENERATOR_VERSION}/openapi-generator-cli-${OPENAPI_GENERATOR_VERSION}.jar -O openapi-generator-cli.jar
      - name: build
        run: sh ./generate.sh
      - name: uninstall openapi-generator
        run: rm openapi-generator-cli.jar
      - name: git commit and push
        run: |
          git config user.name "GitHub Actions"
          git config user.email "actions@github.com"
          BRANCH_NAME="update-$(date +'%Y%m%d%H%M%S')"
          git switch -c "$BRANCH_NAME"
          git add .
          git commit -m "CI: regenerate [skip ci]" --author="H1rono <54711422+H1rono@users.noreply.github.com>"
          git push origin "$BRANCH_NAME"
      - name: create pull request
        run: |
          gh pr create --title "CI: regenerate" --body "" --base main --assignee H1rono
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}