From 26cba0bf1b8a541ddff0b1846d09d67f2d102cc3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 00:30:25 +0000 Subject: [PATCH 1/2] feat(github-actions): Automate Prettier workflow Updates the Prettier workflow to run automatically on pushes to the main branch and on pull requests. This eliminates the need for manual triggering and ensures consistent code formatting. The workflow will now automatically commit any formatting fixes. --- .github/workflows/prettier.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 4eb1dc3..730d50f 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -2,9 +2,13 @@ name: Format Code with Prettier -# This workflow is triggered manually from the Actions tab. +# This workflow is triggered on pushes to the `main` branch and on pull +# requests. on: - workflow_dispatch: + push: + branches: + - main + pull_request: jobs: format: @@ -42,7 +46,6 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "style: Format code with Prettier" - branch: ${{ github.ref }} # The file_pattern is set to all files, ensuring any change made by # Prettier is committed. file_pattern: "**/*.*" From 43e32236c23581c28f83cbc96746a56677fc9eb1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 00:36:03 +0000 Subject: [PATCH 2/2] feat(github-actions): Automate Prettier workflow and update docs Updates the Prettier workflow to run automatically on pushes to the main branch and on pull requests. This eliminates the need for manual triggering and ensures consistent code formatting. The workflow will now automatically commit any formatting fixes. Also updates the corresponding documentation in 'docs/development.prettier-workflow.md' to reflect the new automated behavior. --- docs/development.prettier-workflow.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/docs/development.prettier-workflow.md b/docs/development.prettier-workflow.md index dcef195..cf85aec 100644 --- a/docs/development.prettier-workflow.md +++ b/docs/development.prettier-workflow.md @@ -5,21 +5,18 @@ This repository includes a GitHub Actions workflow that automatically formats al ## Workflow Details - **Workflow File:** [`.github/workflows/prettier.yml`](../.github/workflows/prettier.yml) -- **Trigger:** This workflow is **not** run automatically. It must be triggered manually. -- **Action:** When run, the workflow will: - 1. Check out the code from the branch it was run on. +- **Trigger:** This workflow is triggered automatically on: + - Pushes to the `main` branch. + - Any pull request. +- **Action:** When triggered, the workflow will: + 1. Check out the code from the relevant branch or pull request. 2. Install the necessary dependencies (`npm install`). 3. Run `npx prettier --write .` to format all files. - 4. If any files were changed by Prettier, the workflow will automatically commit the changes back to the same branch with the commit message `style: Format code with Prettier`. + 4. If any files were changed by Prettier, the workflow will automatically commit the changes back to the same branch (for pushes) or the pull request's head branch with the commit message `style: Format code with Prettier`. -## How to Use +## How it Works -To run the formatting workflow: +The workflow runs automatically, so there are no manual steps required. -1. Navigate to the **Actions** tab of the repository on GitHub. -2. In the left sidebar, click on **"Format Code with Prettier"**. -3. Above the list of previous runs, you will see a message: "This workflow has a `workflow_dispatch` event trigger." -4. Click the **"Run workflow"** button. -5. Choose the branch you want to format and click the **"Run workflow"** button again. - -The workflow will then execute, and any formatting changes will be pushed to your chosen branch. This is useful for cleaning up a feature branch before creating a pull request. +- **On the `main` branch:** When code is pushed to `main`, the workflow will run and commit any formatting changes directly to `main`. +- **On Pull Requests:** When you open a pull request, the workflow will run on the code in your branch. If it finds any formatting issues, it will push a new commit to your branch with the fixes. This helps ensure that all code is properly formatted before it gets merged into `main`.