diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000..4eb1dc3 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,48 @@ +# .github/workflows/prettier.yml + +name: Format Code with Prettier + +# This workflow is triggered manually from the Actions tab. +on: + workflow_dispatch: + +jobs: + format: + runs-on: ubuntu-latest + + steps: + # Checks out the repository code so the workflow can access it. + - name: Checkout Code + uses: actions/checkout@v4 + with: + # The GITHUB_TOKEN is required to allow the workflow to push changes + # back to the repository. + token: ${{ secrets.GITHUB_TOKEN }} + + # Sets up the Node.js environment, which is needed to run Prettier. + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" # Using a recent Long-Term Support (LTS) version of Node.js + cache: "npm" # Cache npm dependencies for faster runs + + # Installs the project's dependencies, including Prettier itself, + # as defined in package.json and package-lock.json. + - name: Install Dependencies + run: npm install + + # Runs Prettier to format all files in the repository. + # The --write flag tells Prettier to modify files in-place. + - name: Run Prettier + run: npx prettier --write . + + # This action checks if Prettier made any changes. If so, it commits + # them back to the branch that the workflow was run on. + - name: Commit Changes + 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: "**/*.*" diff --git a/docs/README.md b/docs/README.md index 0e05313..b540477 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,6 +12,7 @@ This directory contains the documentation for the `base` project. - **[Guiding AI with `AGENTS.md`](./agents-md-guide.md)**: An explanation of how to use the `AGENTS.md` file to provide persistent instructions to AI agents. - **[The `package.json` files](./package-json-guide.md)**: An explanation of the `package.json` and `package-lock.json` files used for development tooling. - **[GitHub Workflows](./github-workflows.md)**: An explanation of the CI/CD workflows for linting, testing, and releasing. +- **[Manually Formatting Code with the Prettier Workflow](./prettier-workflow.md)**: A guide to using the manually-triggered workflow to format the codebase. - **[Licensing Information](./licensing.md)**: Details on the MIT License and how to properly attribute copyright. - **[Deploying to Render.com](./render.md)**: Instructions for deploying the project to the Render.com platform. - **[Merging `base` Into an Existing Repository](./merging-base.md)**: A guide on how to incorporate `base` into an existing project. diff --git a/docs/prettier-workflow.md b/docs/prettier-workflow.md new file mode 100644 index 0000000..dcef195 --- /dev/null +++ b/docs/prettier-workflow.md @@ -0,0 +1,25 @@ +# Prettier Workflow + +This repository includes a GitHub Actions workflow that automatically formats all files in the repository using [Prettier](https://prettier.io/), a widely-used code formatter. This ensures a consistent and readable code style across the entire project. + +## 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. + 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`. + +## How to Use + +To run the formatting workflow: + +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. diff --git a/docs/using-github-discussions.md b/docs/using-github-discussions.md index 83536d1..fc25b4d 100644 --- a/docs/using-github-discussions.md +++ b/docs/using-github-discussions.md @@ -1,6 +1,6 @@ # Using GitHub Discussions -GitHub Discussions is a feature designed to be the community forum for your project, right alongside your code. +GitHub Discussions is a feature designed to be the community forum for your project, right alongside your code. It provides a dedicated space for conversations, Q&A, and idea sharing, keeping your issue tracker clean and focused on actionable tasks. ## Issues vs. Discussions: What's the Difference?