Skip to content

Add generic Gathering system for flexible event/meetup management #773

Add generic Gathering system for flexible event/meetup management

Add generic Gathering system for flexible event/meetup management #773

Workflow file for this run

name: Pre-commit fix
on:
workflow_dispatch:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
jobs:
run-pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check if copilot branch
id: check_copilot
run: |
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
if [[ "$BRANCH_NAME" == copilot/* ]]; then
echo "is_copilot=true" >> $GITHUB_OUTPUT
echo "Branch $BRANCH_NAME is a copilot branch"
else
echo "is_copilot=false" >> $GITHUB_OUTPUT
echo "Branch $BRANCH_NAME is not a copilot branch, skipping"
fi
else
# For workflow_dispatch, always run
echo "is_copilot=true" >> $GITHUB_OUTPUT
echo "Manual workflow dispatch, running"
fi
- name: Checkout code
if: steps.check_copilot.outputs.is_copilot == 'true'
uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.ref_name }}
repository: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
if: steps.check_copilot.outputs.is_copilot == 'true'
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install pre-commit
if: steps.check_copilot.outputs.is_copilot == 'true'
run: |
python -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install pre-commit
- name: Run pre-commit
if: steps.check_copilot.outputs.is_copilot == 'true'
run: |
. venv/bin/activate
pre-commit run --all-files
continue-on-error: true
- name: Check for changes
if: steps.check_copilot.outputs.is_copilot == 'true'
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected by pre-commit."
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "No changes made by pre-commit."
echo "changes_detected=false" >> $GITHUB_ENV
fi
- name: Commit and push changes
if: steps.check_copilot.outputs.is_copilot == 'true' && env.changes_detected == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Apply pre-commit fixes"
PUSH_REF="${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.ref_name }}"
git push origin "HEAD:$PUSH_REF"