From c300e4bc3a5bde7cf251c2454b8178640ce8b8e1 Mon Sep 17 00:00:00 2001 From: fboundy Date: Sun, 22 Dec 2024 18:42:22 +0000 Subject: [PATCH 1/2] Create main.yml --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e7009a6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: Test Push Permissions + +on: + workflow_dispatch: + +jobs: + test-push: + name: Test Push to Branch + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Make a Test Change + run: | + echo "Test file generated by bot" > test-file.txt + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Test commit by bot" + + - name: Push Test Change + run: git push From be770810330bc1a406a7fe14913929e76e90f7d1 Mon Sep 17 00:00:00 2001 From: fboundy Date: Sun, 22 Dec 2024 19:31:51 +0000 Subject: [PATCH 2/2] Add black and isort to workflow --- .github/workflows/black.yaml | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/black.yaml diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml new file mode 100644 index 0000000..17a67e1 --- /dev/null +++ b/.github/workflows/black.yaml @@ -0,0 +1,65 @@ +name: Auto-format Code with Debugging + +on: + push: + pull_request: + +jobs: + auto-format: + name: Auto-format and Push Changes + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the repository + - name: Checkout Repository + uses: actions/checkout@v3 + + # Step 2: Set up Python environment + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + # Step 3: Install tools (black and isort) + - name: Install Tools + run: | + echo "Installing tools..." + python -m pip install --upgrade pip + pip install black isort + + # Step 4: Run black and isort to format the code + - name: Run Black and isort + run: | + echo "Running black..." + black . + echo "Running isort..." + isort . + + # Step 5: Commit and push changes if any files were modified + - name: Commit and Push Changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Configuring git user..." + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + echo "Checking for changes..." + git status + + if [ -n "$(git status --porcelain)" ]; then + echo "Changes detected. Inspecting changes..." + git diff + + echo "Staging files..." + git add . + + echo "Committing changes..." + git commit -m "Auto-format code with Black and isort" + + echo "Pushing changes to branch..." + git push + echo "Push completed successfully." + else + echo "No changes detected. Nothing to commit or push." + fi