Skip to content

Generate collection from Google Drive #41

Generate collection from Google Drive

Generate collection from Google Drive #41

name: Generate collection from Google Drive
on:
workflow_dispatch:
jobs:
generate-collection:
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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: Download .mscz files from Google Drive folder
run: |
echo ${{ secrets.GDRIVE_KEYFILE_BASE64 }} | base64 -d > /tmp/gdrive-api-key.json
npm run download-gdrive -- -i ${{ vars.GDRIVE_FOLDER_ID }} -o /tmp/collection -p ".*mscz" -k /tmp/gdrive-api-key.json -v
- name: Create MuseScore generator file
shell: sh
run: |
find /tmp/collection/ -type f -name "*.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: Index collection
run: |
npm run index-collection -- -i /tmp/collection -o public/collection
- name: Create PR with changes
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: renerate collection (${{github.run_number}})"
branch: chore/generate-collection-${{github.run_number}}
title: "chore: generate collection (${{github.run_number}})"
body: |
Regenerated collection from Google Drive folder ${{ vars.GDRIVE_FOLDER_ID }}
labels: "automated"
add-paths: |
public/collection/**