-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (44 loc) · 1.44 KB
/
shrink-credits.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
name: 'Shrink credits'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- credits.json
jobs:
build:
name: 'Shrink credits'
runs-on: ubuntu-latest
steps:
- name: Shrink credits
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/github-script@v6
with:
script: |
const { readFileSync, writeFileSync } = require('fs');
const contents = readFileSync('src/credits.json');
const shrunk = JSON.stringify(JSON.parse(contents));
writeFileSync('credits.json', shrunk);
- name: Checkout gh-pages
id: checkout
run: |
git add credits.json
git stash
git checkout gh-pages
# Prevent conflicts by overwriting the file with the one in the stash
git checkout stash -- credits.json
changes=$(git status --porcelain credits.json | wc -l)
echo "::set-output name=changes::$changes"
- name: Commit and push changes
if: ${{ steps.checkout.outputs.changes != 0 }}
run: |
git config --global user.name 'zbrabot'
git config --global user.email '[email protected]'
# Make sure only the credits.json file gets committed
git reset
git add credits.json
git commit --message "chore(credits): automated update at $(date '+%F %T')"
git push