Try using conditional workflow based on if tagbot is modified. #25
Workflow file for this run
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: Tagbot | ||
on: [pull_request_target] | ||
jobs: | ||
tagbot: | ||
runs-on: ubuntu-24.04 | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check if file has changed | ||
id: file_check | ||
run: | | ||
if git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD | grep -q .github/workflows/tagbot.py; then | ||
echo "tagbot_modified=true" >> $GITHUB_ENV | ||
else | ||
echo "tagbot_modified=false" >> $GITHUB_ENV | ||
fi | ||
- name: Post warning comment | ||
if: env.file_modified == 'true' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: ${{ github.event.pull_request.number }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: "⚠️ Warning: The tagbot.py file has been modified. Please review changes carefully." | ||
}) | ||
- name: set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
- name: Get packages | ||
run: pip install gitpython requests | ||
- name: Tag and comment | ||
if: env.tagbot_modified == 'false' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: python .github/workflows/tagbot.py | ||