Merge branch 'monorepo' of github.com:Qwizi/cs2-battle-bot into monorepo #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "github@actions.com" | |
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 | |
run: | | |
cd api | |
API_VERSION=$(awk -F ' = ' '/version =/ {gsub(/"/, "", $2); print $2}' pyproject.toml) | |
echo "API_RELEASE_VERSION=$API_VERSION" >> $GITHUB_ENV | |
cd ../src | |
BOT_VERSION=$(awk -F ' = ' '/version =/ {gsub(/"/, "", $2); print $2}' pyproject.toml) | |
echo "BOT_RELEASE_VERSION=$BOT_VERSION" >> $GITHUB_ENV | |
- 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: ${{ env.API_RELEASE_VERSION }} | |
Bot Version: ${{ env.BOT_RELEASE_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 }}.' |