Repository navigation
ci: add TechEngineBot final-check comment for important PRs #4
Workflow file for this run
This file contains hidden or 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: final-check | |
| # TechEngineBot leaves one final-check comment on important PRs: | |
| # releases into main, or any PR labeled `final-check`. The comment is | |
| # edited in place on each push, never duplicated. | |
| on: | |
| pull_request: | |
| branches: [develop, main] | |
| types: [opened, synchronize, reopened, ready_for_review, labeled] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: final-check-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| final-check: | |
| if: >- | |
| !github.event.pull_request.draft && | |
| (github.base_ref == 'main' || contains(github.event.pull_request.labels.*.name, 'final-check')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # diff against the base branch | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Validate ES catalog | |
| id: validate | |
| continue-on-error: true | |
| run: python -m app.validate | |
| - name: Tests | |
| id: tests | |
| continue-on-error: true | |
| run: | | |
| python -m pip install pytest | |
| python -m pytest -q | |
| - name: Render comment | |
| env: | |
| VALIDATE_OUTCOME: ${{ steps.validate.outcome }} | |
| TESTS_OUTCOME: ${{ steps.tests.outcome }} | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: python .github/scripts/final_check.py > final-check.md | |
| - name: Post as TechEngineBot | |
| env: | |
| GH_TOKEN: ${{ secrets.TECHENGINEBOT_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| PR: ${{ github.event.pull_request.number }} | |
| shell: bash # -eo pipefail: a failed lookup must stop here, not feed an error body into PATCH | |
| run: | | |
| # Bot account only: never fall back to a personal token. | |
| if [ -z "$GH_TOKEN" ]; then | |
| echo "::warning::TECHENGINEBOT_TOKEN is not set; skipping the comment" | |
| exit 0 | |
| fi | |
| id=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \ | |
| --jq '.[] | select(.user.login == "TechEngineBot" and (.body | startswith("<!-- techenginebot:final-check -->"))) | .id' | head -n1) | |
| if [ -n "$id" ]; then | |
| gh api -X PATCH "repos/$REPO/issues/comments/$id" -F body=@final-check.md > /dev/null | |
| else | |
| gh api "repos/$REPO/issues/$PR/comments" -F body=@final-check.md > /dev/null | |
| fi | |
| - name: Fail on failed checks | |
| if: steps.validate.outcome != 'success' || steps.tests.outcome != 'success' | |
| run: exit 1 |