-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (92 loc) · 3.8 KB
/
index-collection.yaml
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
name: Generate collection from MuseScore files
on:
workflow_dispatch:
pull_request:
paths:
- "public/collection/**"
jobs:
generate-collection:
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make sure the indexer is on the latest ref of the PR branch
run: |
git fetch origin ${{ github.event.pull_request.head.ref }}:${{ github.event.pull_request.head.ref }}
git checkout ${{ github.event.pull_request.head.ref }}
git branch --set-upstream-to=origin/${{ github.event.pull_request.head.ref }}
- name: Skip if current commit is from the indexer
run: |
LAST_EMAIL=$(git log -1 --pretty=format:%ae)
if [ "$LAST_EMAIL" = "[email protected]" ]; then
echo "Last commit was from the indexer, skipping"
exit 78
fi
- name: Get apt dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq libegl-dev libasound2 libjack0 librust-gobject-sys-dev libnss3 xvfb
version: 1.0
- name: Setup MuseScore AppImage
run: |
make download-musescore
./musescore_3.6.2.AppImage --appimage-extract
- name: Restore npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: |
npm ci
- name: Make sure any mscz files are in folders with the same name
run: |
find public/collection -type f -name "*.mscz" | while read FILE; do
FILENAME=$(basename "$FILE")
FOLDERNAME=$(basename "$(dirname "$FILE")")
if [ "$FILENAME" != "$FOLDERNAME.mscz" ]; then
BASE=$(basename "$FILE" .mscz)
NEWFOLDER="$(dirname "$FILE")/$BASE"
NEWFILE="$(dirname "$FILE")/$BASE/$FILENAME"
mkdir -v "$NEWFOLDER"
git mv -v "$FILE" "$NEWFILE"
fi
done
# don't commit if there are no changes
git config --global user.email "[email protected]"
git config --global user.name "cadern.in indexer"
git diff --staged --quiet || git commit -m "chore: move mscz files to folders with the same name (${{github.run_number}})"
- name: Create MuseScore generator file
shell: sh
run: |
git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD | grep ".mscz" | jq -R -s 'split("\n") | map(select(.!="") | sub(".mscz";"") | {"in":"\(.).mscz", "out": [[ "\(.)_",".svg"],[ "\(.)_",".midi"],"\(.).midi","\(.).metajson"]})' > media-generation.json
head media-generation.json
- name: Create svg, midi and metajson from mscz
shell: sh
run: |
xvfb-run squashfs-root/AppRun -j media-generation.json
find /tmp/collection/ -type f -name "*.svg" -a -name "*.midi" | head
- name: Copy current collection to temporary folder
run: |
cp -r public/collection /tmp/collection
- name: Index collection
run: |
npm run index-collection -- -i /tmp/collection -o public/collection --verbose
git add -v public/collection
- uses: EndBug/add-and-commit@v9
with:
message: "chore: generate collection from mscz files (${{github.run_number}})"
add: "public/collection"
push: true
author_name: "cadern.in indexer"
author_email: "[email protected]"
- uses: lhotari/action-upterm@v1
if: failure()
with:
wait-timeout-minutes: 5