Update API and regenerate project #11
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: Update API and regenerate project | |
on: | |
workflow_dispatch: # Manual trigger | |
repository_dispatch: # when triggered remotely | |
types: | |
- api_published # trigger name | |
# push: | |
# paths: | |
# - 'nebius-api' | |
# - 'nebius-api/**' | |
jobs: | |
update-and-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository with submodules | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install .[generators,dev] | |
pip install tox | |
- uses: bufbuild/buf-action@v1 | |
with: | |
token: ${{ secrets.BUF_TOKEN }} | |
setup_only: true | |
- name: Run generation script | |
run: | | |
make | |
- name: Check for Changes | |
id: check_changes | |
run: | | |
git add . | |
if git diff --cached --quiet; then | |
echo "changes_detected=false" >> $GITHUB_ENV | |
else | |
echo "changes_detected=true" >> $GITHUB_ENV | |
fi | |
- name: Bump version | |
if: env.changes_detected == 'true' | |
run: | | |
python src/scripts/version_updater.py ./pyproject.toml patch | |
git add pyproject.toml | |
- name: Test | |
if: env.changes_detected == 'true' | |
run: | | |
tox | |
tox -e test_earliest | |
- name: Create or update PR | |
if: env.changes_detected == 'true' | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
branch: api-auto-update | |
title: "Auto-update: API change" | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
commit-message: "Auto-update: API change" | |
body: | | |
This PR was automatically created by GitHub Actions. It updates the API and regenerates necessary files. | |
base: main | |
delete-branch: true | |
labels: | | |
api update | |
automated pr | |
# enable after adding an approver robot | |
# - name: Auto approve | |
# if: steps.cpr.outputs.pull-request-operation == 'created' | |
# run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}" | |
# env: | |
# GH_TOKEN: ${{ secrets.APPROVER_TOKEN }} | |
- name: Enable Pull Request Automerge | |
if: steps.cpr.outputs.pull-request-operation == 'created' | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} | |
merge-method: squash |