Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cI): allow PR autoformatting with a label #1712

Merged
merged 10 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/format-website-on-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Format website code

on:
workflow_dispatch:

pull_request:
types: [synchronize, labeled]
paths:
- 'website/**'
jobs:
build:
format:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'format_me'))
permissions:
contents: write
runs-on: ubuntu-latest
Expand All @@ -13,12 +17,20 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Cache .npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/**/package-lock.json') }}

- name: NPM install and format website
working-directory: website
run: |
Expand All @@ -31,4 +43,4 @@ jobs:
git config --global user.email '[email protected]'
git add -A
git commit -m "Automated code formatting" || echo "No changes to commit"
git push
git push origin HEAD:${{ github.head_ref }}