Skip to content

Commit

Permalink
fix: make prettier PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Mar 3, 2023
1 parent eef3c1c commit fe45bd9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/prettier.yml
Expand Up @@ -7,29 +7,44 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
contents: read

jobs:
run:
name: 🤔
name: Can the code be prettier? 🤔
runs-on: ubuntu-latest
# workflow_dispatch always lets you select the branch ref, even though in this case we only ever want to run the action on `main` this we need an if check
if: ${{ github.ref_name == 'main' }}
permissions:
contents: write # for gr2m/create-or-update-pull-request-action to push local changes
pull-requests: write # for gr2m/create-or-update-pull-request-action to create a PR
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
- uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci --ignore-scripts --only-dev
- uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 # v3
- uses: actions/cache@v3
with:
path: node_modules/.cache/prettier/.prettier-cache
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
- name: check if workflows needs prettier
run: npx prettier --cache --check ".github/workflows/**/*.yml" || (echo "An action can't make changes to actions, you'll have to run prettier manually" && exit 1)
- run: npx prettier --ignore-path .gitignore --cache --write .
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # v9
- run: npm run prettier
- run: git restore .github/workflows
name: Remove changes to workflow files, as it's a bad idea to let robots change their own workflow definitions
- uses: gr2m/create-or-update-pull-request-action@v1.9.1
env:
GITHUB_TOKEN: ${{ secrets.GH_PR_TOKEN }}
with:
default_author: github_actions
commit: --no-verify
message: 'chore(prettier): 🤖 ✨'
author: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
branch: actions/prettier-if-needed
title: 'chore(prettier): fix unformatted files'
body: A robot ran `npm run prettier` and made this PR.
commit-message: 'chore(prettier): 🤖 ✨'
labels: 🤖 bot
1 change: 1 addition & 0 deletions renovate.json
Expand Up @@ -5,6 +5,7 @@
"github>sanity-io/renovate-presets//ecosystem/automerge",
":assignAndReview(team:ecosystem)"
],
"reviewers": ["team:ecosystem"],
"packageRules": [
{
"matchPackageNames": ["semantic-release-license"],
Expand Down

0 comments on commit fe45bd9

Please sign in to comment.