-
Notifications
You must be signed in to change notification settings - Fork 3.6k
71 lines (65 loc) · 2.19 KB
/
post-merge.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Update cards and screenshots
on:
push:
branches:
- master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SKIP_REST: false
jobs:
update-cards-and-screenshots:
runs-on: ubuntu-latest
# Don't push changes to main branches in forks as this causes merge conflicts
if: ${{ !github.event.repository.fork }}
permissions:
contents: write
# running two copies of this job at once can create race conditions
# and will usually cause the most recent workflow to fail. It is
# preferable to always have the most up to date workflow succeed
# so we cancel this job whenever a newer one is started.
concurrency:
group: post-merge
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install job dependencies
run: npm install
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Generate cards.json
run: node generators/generateCards.js
- name: Check for cards changes
run: |
if git diff --quiet public/cards.json; then
echo "No changes to commit"
echo "SKIP_REST=true" >> $GITHUB_ENV
else
git add public/cards.json
git commit -m "(CI) cards.json Generation"
fi
- name: Format cards
if: env.SKIP_REST != 'true'
run: |
if [ ! -f .prettierrc ]; then
echo ".prettierrc not found"
echo "terminating workflow..."
exit 1;
fi
npx prettier public/cards.json --write
git add public/cards.json
git commit -m "(CI) Format cards" || echo "No changes to commit"
- name: Generate screenshots
if: env.SKIP_REST != 'true'
run: |
node generators/generateScreenshot.js
git add Art/**/icon.png
git commit -m "(CI) Screenshot Generation" || echo "No changes to commit"
- name: Push changes
if: env.SKIP_REST != 'true'
run: git push origin master