Skip to content

Try using conditional workflow based on if tagbot is modified. #25

Try using conditional workflow based on if tagbot is modified.

Try using conditional workflow based on if tagbot is modified. #25

Workflow file for this run

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

Check failure on line 15 in .github/workflows/tagbot.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/tagbot.yml

Invalid workflow file

You have an error in your yaml syntax on line 15
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