diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml new file mode 100644 index 00000000..9aa5501f --- /dev/null +++ b/.github/workflows/generate.yml @@ -0,0 +1,55 @@ +name: Run generate + +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + workflow_dispatch: + +permissions: + contents: write # Required for merging the PR + pull-requests: write # Required for managing pull requests + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + cache: pip + - name: Run generate script + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + ./generate.py + - name: Commit any changes + id: commit + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if [[ $(git status --porcelain) ]]; then + git add . + git commit -m "Automated update from generate.py" + echo "Changes committed." + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "No changes to commit." + echo "changes=false" >> $GITHUB_OUTPUT + fi + - name: Push changes + if: steps.commit.outputs.changes == 'true' + run: | + git push + gh pr comment ${{ github.event.pull_request.number }} \ + --body "Automated changes were made by running \`generate.py\`. Please review the updates." + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e98eb67c..010cde03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,22 +26,6 @@ jobs: pip install pydocstyle pydocstyle . - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.x - cache: pip - - name: Verify dockerfiles - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - ./generate.py - git diff --exit-code - env-check: runs-on: ubuntu-latest permissions: @@ -139,7 +123,6 @@ jobs: complete: needs: - lint - - generate - env-check - docker-build runs-on: ubuntu-latest