Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
Add automatic Prettier GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Aug 20, 2021
1 parent e07f595 commit ae02ae6
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 8 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Prettier

# This action works with pull requests and pushes
on:
- push

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}

# Make sure @sourcegraph/prettierrc is installed
- uses: actions/setup-node@v2
with:
node-version: '14'
cache: yarn
run: yarn

- name: Read package.json
id: read_package_json
run: |
JSON=$(cat package.json)
echo "::set-output name=packageJson::${JSON//'%'/'%25'}"
- name: Prettier
uses: creyD/prettier_action@v3.3
with:
# Take prettier version from package.json to stay in sync and support upgrades through Renovate
prettier_version: ${{fromJson(steps.read_package_json.outputs.packageJson).devDependencies.prettier}}
prettier_options: --write '**/*.{js,css,scss,ts,tsx,md,html,yml,yaml,json}'
commit_message: Prettier
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.DS_Store
yarn.lock
.yarn-integrity
node_modules
docs/server/config/site.md
.idea
/.bin/
.vscode/settings.json
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
website/.cache/
website/public/

# Prettier chokes on Go template syntax
_resources/templates/

# Old blog content
blogposts/201?/
blogposts/2020/
blogposts/liveblogs/dotgo/
blogposts/liveblogs/github-universe/
blogposts/liveblogs/gophercon/
blogposts/liveblogs/graphql-summit/
blogposts/liveblogs/strange-loop/
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "EditorConfig.EditorConfig"],
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true,
}
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"scripts": {
"prettier": "prettier --write '**/*.{js,css,scss,ts,tsx,md,html,yml,yaml,json}' --list-different",
"prettier-check": "yarn run prettier --write=false"
},
"devDependencies": {
"@sourcegraph/prettierrc": "^3.0.3",
"prettier": "^2.3.2"
}
}
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./website/node_modules/@sourcegraph/prettierrc')
module.exports = require('@sourcegraph/prettierrc')
4 changes: 0 additions & 4 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint .",
"stylelint": "stylelint --quiet 'src/**/*.scss'",
"prettier": "prettier '**/*.{js?(on),ts?(x),md}' --write --list-different",
"prettier-check": "yarn run prettier --write=false",
"deploy": "yarn run build && firebase deploy"
},
"devDependencies": {
"@sourcegraph/eslint-config": "^0.25.1",
"@sourcegraph/prettierrc": "^3.0.3",
"@sourcegraph/stylelint-config": "^1.3.0",
"@sourcegraph/tsconfig": "^4.0.1",
"@types/bootstrap": "5.0.15",
Expand All @@ -79,7 +76,6 @@
"eslint": "7.32.0",
"eslint-webpack-plugin": "^3.0.1",
"gatsby-cli": "^2.19.1",
"prettier": "^2.3.2",
"slugify": "^1.5.3",
"stylelint": "^13.13.1",
"stylelint-scss": "^3.20.1",
Expand Down
2 changes: 1 addition & 1 deletion website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12255,7 +12255,7 @@ prepend-http@^2.0.0:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=

prettier@^2.0.5, prettier@^2.3.2:
prettier@^2.0.5:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@sourcegraph/prettierrc@^3.0.3":
version "3.0.3"
resolved "https://registry.npmjs.org/@sourcegraph/prettierrc/-/prettierrc-3.0.3.tgz#51bfa9b2588fe35121593fa877143e6373028289"
integrity sha512-FQ1/Ued4I02R0JkrHHofDN163juVxUnPALzfxPZrDZUHv+c3jHjfZhmTHEz+Wd+g3b7MFk0fkj36nZSnvPyU8A==

prettier@^2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==

0 comments on commit ae02ae6

Please sign in to comment.