Skip to content

fix: dingens lol haher #146

fix: dingens lol haher

fix: dingens lol haher #146

name: Generate OpenApi
on:
pull_request:
workflow_dispatch:
jobs:
generate-docs:
permissions:
contents: write
pull-requests: write
name: Genereate Api docs
runs-on: ubuntu-20.04
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: user
POSTGRES_DB: beerpong
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 2
- name: Check recent commit authors
id: check_authors
run: |
# Fetch the PR base branch
git fetch origin ${{ github.base_ref }}
# Get the merge base between the PR head and base
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }})
# Check the commits between the merge base and HEAD
COMMIT_AUTHORS=$(git log $MERGE_BASE..HEAD --format='%h - %cn <%ce> - %s')
echo "Commit authors since merge base:"
echo "$COMMIT_AUTHORS"
if echo "$COMMIT_AUTHORS" | grep -q "github-actions"; then
echo "has_bot_author=true" >> $GITHUB_OUTPUT
echo "A recent commit was authored by a GitHub bot. Stopping the workflow."
exit 0 # This will stop the workflow without failing it
else
echo "has_bot_author=false" >> $GITHUB_OUTPUT
echo "No recent commits by GitHub bot found. Continuing the workflow."
fi
shell: bash
- name: Set up JDK 21 corretto
if: steps.check_authors.outputs.has_bot_author != 'true'
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
cache: "maven"
- name: Cache Maven packages
if: steps.check_authors.outputs.has_bot_author != 'true'
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- run: mvn verify
if: steps.check_authors.outputs.has_bot_author != 'true'
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: user
POSTGRES_URL: jdbc:postgresql://localhost:5432/beerpong
API_BASE_URL: http://localhost:8080/
working-directory: api
- run: sed -i 's#"\*/\*"#"application/json"#g' ./mobile-app/api/generated/openapi.json
if: steps.check_authors.outputs.has_bot_author != 'true'
- name: Cache npm packages
if: steps.check_authors.outputs.has_bot_author != 'true'
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js
if: steps.check_authors.outputs.has_bot_author != 'true'
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: "mobile-app/package-lock.json"
- run: npm ci && npm run gen-types && npm run format
if: steps.check_authors.outputs.has_bot_author != 'true'
working-directory: mobile-app
- uses: stefanzweifel/git-auto-commit-action@v5
if: steps.check_authors.outputs.has_bot_author != 'true'
with:
commit_message: "chore: update openapi types"