Skip to content

Commit c88ebce

Browse files
authored
Merge pull request #2728 from pg56714/chore/add-prettier-workflow
chore: add prettier workflow
2 parents 3b1cafd + 4fc8425 commit c88ebce

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

.github/workflows/post-merge.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
name: Update cards and screenshots
1+
name: Update cards, screenshots, and fix code style
22

33
on:
44
push:
55
branches:
66
- master
7+
78
env:
89
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
910
SKIP_REST: false
1011

1112
jobs:
12-
update-cards-and-screenshots:
13+
update-cards-and-screenshots-and-fix-code-style:
1314
runs-on: ubuntu-latest
1415
# Don't push changes to main branches in forks as this causes merge conflicts
1516
if: ${{ !github.event.repository.fork }}
@@ -37,6 +38,7 @@ jobs:
3738
run: |
3839
git config --global user.name "GitHub Actions"
3940
git config --global user.email "actions@github.com"
41+
4042
- name: Generate cards.json
4143
run: node generators/generateCards.js
4244

@@ -49,23 +51,27 @@ jobs:
4951
git add public/cards.json
5052
git commit -m "(CI) cards.json Generation"
5153
fi
52-
- name: Format cards
53-
if: env.SKIP_REST != 'true'
54-
run: |
55-
if [ ! -f .prettierrc ]; then
56-
echo ".prettierrc not found"
57-
echo "terminating workflow..."
58-
exit 1;
59-
fi
60-
npx prettier public/cards.json --write
61-
git add public/cards.json
62-
git commit -m "(CI) Format cards" || echo "No changes to commit"
54+
6355
- name: Generate screenshots
6456
if: env.SKIP_REST != 'true'
6557
run: |
6658
node generators/generateScreenshot.js
6759
git add Art/**/icon.png
6860
git commit -m "(CI) Screenshot Generation" || echo "No changes to commit"
61+
6962
- name: Push changes
7063
if: env.SKIP_REST != 'true'
7164
run: git push origin master
65+
66+
- name: Run Prettier to fix code style
67+
id: prettier-run
68+
run: |
69+
npm run prettier:fix
70+
echo "filecount=$(git status -s -uno | wc -L)" >> $GITHUB_OUTPUT
71+
72+
- name: Commit Prettier changes
73+
if: ${{ steps.prettier-run.outputs.filecount > 0 }}
74+
run: |
75+
git add .
76+
git commit -m "(CI) Run Prettier"
77+
git push origin master

.prettierignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
.prettierrc
1+
.prettierrc
2+
.github/
3+
node_modules/
4+
public/
5+
package*.json

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,19 @@ Now for the fun part! Inside the `Art/` folder:
7272
- Create a new directory named: <github_username>-<art_name> eg. `mattcsmith-helloworld`.
7373
- Inside **your** folder, create an `index.html` file
7474
- Inside **your** folder, create an `styles.css` file
75-
- Inside **your** folder, create an `meta.json` file
76-
to specify your art name, github author and github link
77-
Note: copy the following snippet and replace only the values with your own details,
78-
Do not change the JSON keys.
75+
- Inside **your** folder, create an `meta.json` file
76+
to specify your art name, github author and github link
77+
Note: copy the following snippet and replace only the values with your own details,
78+
Do not change the JSON keys.
79+
7980
```json
8081
// Example
8182
{
82-
"artName": "hello world",
83-
"githubHandle": "mattcsmith"
83+
"artName": "hello world",
84+
"githubHandle": "mattcsmith"
8485
}
8586
```
87+
8688
- Use these to create your **animated artwork** — let your creativity flow!
8789

8890
⚠️ It is important to name the directory and your files exactly as mentioned above ⚠️
@@ -96,6 +98,7 @@ Remembering to first pull down the recent changes from to the upstream, commit y
9698
- [Aldo's Contributing to Github video](https://www.youtube.com/watch?v=uQLNFRviB6Q)
9799

98100
### 6. [ OPTIONAL ] Tweet about your progress
101+
99102
Optinonally you can [Tweet about making your first Hacktoberfest pull request](https://ctt.ac/36L1C) on X
100103

101104
---

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
2-
"name": "AnimationNation2024",
2+
"name": "animationnation2024",
33
"version": "1.0.0",
44
"main": "index.js",
55
"license": "MIT",
6+
"scripts": {
7+
"prettier": "npx prettier . --check --config ./.prettierrc",
8+
"prettier:fix": "npx prettier . --check --write --config ./.prettierrc"
9+
},
610
"devDependencies": {
711
"prettier": "^2.8.8",
812
"puppeteer": "^23.5.0",

0 commit comments

Comments
 (0)