diff --git a/.github/workflows/format-and-commit.yml b/.github/workflows/format-and-commit.yml new file mode 100644 index 0000000000..eebed76258 --- /dev/null +++ b/.github/workflows/format-and-commit.yml @@ -0,0 +1,78 @@ +name: Format, Lint, Build and Commit + +on: + workflow_dispatch: + +jobs: + format-and-commit: + name: Format, Lint, Build and Commit Changes + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + # Use a token that can push to the repository + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + cache: npm + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Install dependencies + run: make deps-dev + + - name: Format code + run: make fmt + + - name: Lint code + run: make lint + + - name: Build code + run: make build + + - name: Run agent-finish + run: make agent-finish + + - name: Check for changes + id: check-changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "changes=true" >> "$GITHUB_OUTPUT" + echo "Changes detected:" + git status --short + else + echo "changes=false" >> "$GITHUB_OUTPUT" + echo "No changes detected" + fi + + - name: Commit changes + if: steps.check-changes.outputs.changes == 'true' + run: | + git add -A + git commit -m "Auto-format, lint, and build changes + + This commit was automatically generated by the format-and-commit workflow. + + Changes include: + - Code formatting (make fmt) + - Linting fixes (make lint) + - Build artifacts updates (make build) + - Agent finish tasks (make agent-finish) + " + git push origin "${{ github.ref_name }}" + + - name: No changes to commit + if: steps.check-changes.outputs.changes == 'false' + run: echo "No changes were made during formatting, linting, and building." \ No newline at end of file