Skip to content

Format code with prettier (https://prettier.io/) #52

Format code with prettier (https://prettier.io/)

Format code with prettier (https://prettier.io/) #52

Workflow file for this run

name: Continuous Integration
# This action works only on pushes to the main branch
on:
push:
branches:
- main
# for testing
- prettier-github-action-3
jobs:
prettier:
runs-on: ubuntu-latest
if: github.repository == 'ObieSource/obiesource.github.io'
steps:
# We want this GitHub Action re-format code on the main branch.
# But we also have a branch protection rule so that people don't
# accidentally push to the main branch.
# So we use a GitHub Personal Access Token of an admin (Ajai right now) to push.
- name: Checkout
uses: actions/checkout@v3
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
token: ${{ secrets.PAT }}
- name: Set git origin url so prettier_action knows how to push using the GitHub Personal Access Token
run: git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}
- name: Prettify code
uses: creyD/prettier_action@v4.3
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
# This part is also where you can pass other options, for example:
prettier_options: "--write ."
commit_message: "Format code with prettier (https://prettier.io/)"
commit_description: "This commit was automatically generated by a GitHub Action (see .github/workflows/format.yml)."
github_token: ${{ secrets.PAT }}