Skip to content

Some testing

Some testing #10

name: Generate Client
on:
push:
branches:
- master
- monorepo
paths:
- 'api/**'
jobs:
generate-schema:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}
- name: "Install Poetry"
run: "pipx install poetry"
- name: Set up Python ${{matrix.python-version}}
uses: "actions/setup-python@v5"
with:
python-version: 3.11
- name: "Install the project"
working-directory: api
run: "poetry install"
- name: Generate API schema and extract version
run: |
cd api
poetry run python src/manage.py spectacular --file openapi.json --validate --format openapi-json
echo "Schema generated"
- name: Commit and push changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions "
git add .
if [[ -n "$(git diff --cached)" ]]; then
git commit -m "Generate OpenAPI schema [skip ci]"
git push
else
echo "No changes to commit"
fi
- name: Extract versions from pyproject.toml
id: extract_versions
run: |
API_VERSION=$(awk -F ' = ' '/version =/ {gsub(/"/, "", $2); print $2}' ./api/pyproject.toml)
BOT_VERSION=$(awk -F ' = ' '/version =/ {gsub(/"/, "", $2); print $2}' ./src/pyproject.toml)
echo "::set-output name=api_version::$API_VERSION"
echo "::set-output name=bot_version::$BOT_VERSION
shell: /usr/bin/bash -e {0}
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '${{ github.repository }} successfully generated openapi schema.'
# - name: Trigger Client Generation
# uses: peter-evans/repository-dispatch@v2
# with:
# token: ${{ secrets.RELEASE_GIT_TOKEN }}
# repository: Qwizi/cs2-battle-bot-api-client
# event-type: generate-client
- name: Release New Version
uses: softprops/action-gh-release@v1
with:
name: Build-${{ github.run_id }}
tag_name: Build-${{ github.run_id }}
token: ${{ secrets.RELEASE_GIT_TOKEN }}
body: |
API Version: ${{ steps.extract_metadata.outputs.api_version }}
Bot Version: ${{ steps.extract_metadata.outputs.bot_version }}
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: 'Successfuly released new version of ${{github.repository}}. API Version: ${{ env.API_RELEASE_VERSION }}, Bot Version: ${{ env.BOT_RELEASE_VERSION }}.'