-
Notifications
You must be signed in to change notification settings - Fork 3
124 lines (96 loc) · 3.13 KB
/
check.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Check
on: [push, pull_request, workflow_dispatch]
jobs:
validate:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Validate JSON and YAML
id: json-yaml-validate
uses: GrantBirki/json-yaml-validate@v3
with:
use_gitignore: false
- name: Validate Resource
id: resource-validate
run: python ./scripts/resource_validator.py ./local-files/resource
- name: Send Notification to Discord
uses: sarisia/actions-status-discord@v1
if: failure() && github.event_name != 'pull_request'
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
title: "Validate"
format:
runs-on: ubuntu-22.04
needs: validate
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install Dependencies
run: npm install --global prettier sort-json
- name: Run Prettier
run: prettier --write "local-files/genericTrans/index/*.json" "local-files/genericTrans/lyrics/*.json" "local-files/generic.json" "local-files/localization.json"
# Do not ever sort lyrics alphabetically...
- name: Sort JSON files
run: |
find local-files/genericTrans/index -type f -exec sort-json {} +
sort-json local-files/generic.json
sort-json local-files/localization.json
- name: Authorize Git
run: |
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
- name: Commit Changes
run: |
git commit -am "chore(format): Format and Sort JSON files"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git push origin HEAD:${{ github.head_ref }}
else
git push origin HEAD
fi
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
continue-on-error: true
update:
runs-on: ubuntu-22.04
needs: [validate, format]
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authorize Git
run: |
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
- name: Write Branch and Hash Info
run: |
branch=$(git rev-parse --abbrev-ref HEAD)
hash=$(git rev-parse --short=7 HEAD)
echo "$branch.$hash" > version.txt
echo "VERSION=$branch.$hash" >> $GITHUB_ENV
- name: Commit Changes
run: |
git pull
git commit -am "chore(update): Update Version Info"
git push origin HEAD
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Send Notification to Discord
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
title: "Update"