From 147ec2b5fcd3c69e650e8f1fce4f32ca6d13330f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:25:12 +0000 Subject: [PATCH 1/6] Restrict deployments to main and master branches Updated the deployment workflow to trigger only on pushes to main or master branches, ensuring deployments only occur after code is merged to protected branches. --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f769b2fe..ca7b7bfb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,7 +6,7 @@ name: VPS on: push: - branches: [main] + branches: [main, master] concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 9d53d88b8993014cc6c9f87ff7a2fd9108d58640 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:28:49 +0000 Subject: [PATCH 2/6] Update gofmt workflow to run on all PR commits unless 'no-fmt' label present Modified the Go formatting workflow to: - Trigger on every PR commit (opened, reopened, synchronize) - Skip formatting only when PR has 'no-fmt' label - Auto-commit formatting fixes on draft PRs (respects 'no-fmt' label) - Removed dependency on 'style' label for auto-commits This ensures consistent code formatting across all PRs by default, with an opt-out mechanism via the 'no-fmt' label. --- .github/workflows/gofmt.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index 5ceaec66..def0693e 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -2,7 +2,7 @@ name: Go Fmt on: pull_request: - types: [labeled] + types: [opened, reopened, synchronize, labeled, unlabeled] push: branches: - main @@ -16,8 +16,7 @@ jobs: if: > github.event_name == 'push' || (github.event_name == 'pull_request' && - github.event.action == 'labeled' && - github.event.label.name == 'style') + !contains(github.event.pull_request.labels.*.name, 'no-fmt')) runs-on: ubuntu-latest strategy: matrix: @@ -48,7 +47,7 @@ jobs: if: > github.event.pull_request.draft && github.event.pull_request.head.repo.full_name == github.repository && - contains(github.event.pull_request.labels.*.name, 'style') + !contains(github.event.pull_request.labels.*.name, 'no-fmt') uses: stefanzweifel/git-auto-commit-action@v6.0.1 with: commit_message: apply coding style fixes From a6e3a9c1a26d53b3ec3fe292ccf42e5dedf5ea11 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:30:24 +0000 Subject: [PATCH 3/6] Remove master branch support and disable gofmt on main pushes Changes: - Remove 'master' branch from all workflow triggers (deploy.yml, tests.yml) - Remove push trigger on main from gofmt.yml to prevent auto-formatting on merged PRs - Clean up gofmt.yml by removing main branch handling logic and PR creation steps All workflows now only target the 'main' branch, and gofmt only runs on pull requests (unless 'no-fmt' label is present). --- .github/workflows/deploy.yml | 2 +- .github/workflows/gofmt.yml | 39 ++---------------------------------- .github/workflows/tests.yml | 2 +- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca7b7bfb..f769b2fe 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,7 +6,7 @@ name: VPS on: push: - branches: [main, master] + branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index def0693e..59ac97df 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -3,9 +3,6 @@ name: Go Fmt on: pull_request: types: [opened, reopened, synchronize, labeled, unlabeled] - push: - branches: - - main permissions: contents: write @@ -14,9 +11,8 @@ permissions: jobs: gofmt: if: > - github.event_name == 'push' || - (github.event_name == 'pull_request' && - !contains(github.event.pull_request.labels.*.name, 'no-fmt')) + github.event_name == 'pull_request' && + !contains(github.event.pull_request.labels.*.name, 'no-fmt') runs-on: ubuntu-latest strategy: matrix: @@ -58,34 +54,3 @@ jobs: commit_user_email: ${{ secrets.GUS_GH_EMAIL }} commit_author: gocanto branch: ${{ github.event.pull_request.head.ref }} - - - name: Create branch for formatting changes - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: | - if ! git diff --quiet; then - BRANCH_NAME="gofmt-fixes-$(date +%Y%m%d-%H%M%S)" - git checkout -b $BRANCH_NAME - git config user.name "GitHub Actions" - git config user.email "${{ secrets.GUS_GH_EMAIL }}" - git add . - git commit -m "Apply Go formatting fixes" - git push origin $BRANCH_NAME - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - echo "HAS_CHANGES=true" >> $GITHUB_ENV - else - echo "No formatting changes needed" - echo "HAS_CHANGES=false" >> $GITHUB_ENV - fi - - - name: Create Pull Request - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && env.HAS_CHANGES == 'true' }} - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Apply Go formatting fixes - title: "Auto: Apply Go formatting fixes" - body: | - This PR was automatically created by the Go Fmt GitHub Action. - It applies Go formatting standards to the codebase. - branch: ${{ env.BRANCH_NAME }} - base: main diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d9807ae..181b1a0a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: pull_request: types: [opened, reopened, ready_for_review, synchronize, labeled] push: - branches: [main, master] + branches: [main] jobs: test: From 2feeba641c909649edd2209b17b70a2228de3ef3 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:32:56 +0000 Subject: [PATCH 4/6] Enable auto-apply formatting changes on all PRs Removed draft PR restriction from auto-commit logic, allowing gofmt to automatically apply formatting changes on all pull requests (unless 'no-fmt' label is present). Security: Auto-commits only apply to PRs from the same repository, not forks. --- .github/workflows/gofmt.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index 59ac97df..fa2f83c3 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -41,7 +41,6 @@ jobs: - name: Commit Changes if: > - github.event.pull_request.draft && github.event.pull_request.head.repo.full_name == github.repository && !contains(github.event.pull_request.labels.*.name, 'no-fmt') uses: stefanzweifel/git-auto-commit-action@v6.0.1 From db2c86f4e6678cbd421ab58430c94012e5882b5e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:36:28 +0000 Subject: [PATCH 5/6] Simplify gofmt workflow to properly commit formatting changes Removed confusing "dry run" step and streamlined the workflow to: 1. Run gofmt which modifies files in place 2. Auto-commit any formatting changes directly to the PR The git-auto-commit-action automatically detects changes made by gofmt and commits them to the PR branch. If no changes are detected, it skips the commit step. --- .github/workflows/gofmt.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index fa2f83c3..aae5565a 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -34,12 +34,7 @@ jobs: - name: Run Formatter run: git ls-files '*.go' | xargs gofmt -w -s - - name: Check for formatting changes (dry run) - run: | - git diff --exit-code || echo "::warning::Formatting changes would be applied in normal mode" - continue-on-error: true - - - name: Commit Changes + - name: Commit Formatting Changes if: > github.event.pull_request.head.repo.full_name == github.repository && !contains(github.event.pull_request.labels.*.name, 'no-fmt') From 844fd07ade96158e828718270eb26108009c7e9e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 06:45:14 +0000 Subject: [PATCH 6/6] Refactor gofmt workflow to remove redundant conditional checks Simplified workflow conditions by removing redundancy: - Job-level: Removed unnecessary github.event_name check (workflow only triggers on PRs) - Step-level: Removed duplicate no-fmt label check (already enforced at job level) The workflow now has cleaner logic while maintaining the same behavior: - Runs on all PRs unless 'no-fmt' label is present - Auto-commits only to same-repo PRs (not forks) --- .github/workflows/gofmt.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index aae5565a..2c940c22 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -10,9 +10,7 @@ permissions: jobs: gofmt: - if: > - github.event_name == 'pull_request' && - !contains(github.event.pull_request.labels.*.name, 'no-fmt') + if: "!contains(github.event.pull_request.labels.*.name, 'no-fmt')" runs-on: ubuntu-latest strategy: matrix: @@ -35,9 +33,7 @@ jobs: run: git ls-files '*.go' | xargs gofmt -w -s - name: Commit Formatting Changes - if: > - github.event.pull_request.head.repo.full_name == github.repository && - !contains(github.event.pull_request.labels.*.name, 'no-fmt') + if: github.event.pull_request.head.repo.full_name == github.repository uses: stefanzweifel/git-auto-commit-action@v6.0.1 with: commit_message: apply coding style fixes