Skip to content

Commit

Permalink
Add workflow for publishing to Github Pages
Browse files Browse the repository at this point in the history
Github Pages: Build workflow and publish
  • Loading branch information
tskarhed committed May 13, 2023
2 parents b79b235 + 0051535 commit 6473192
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");

module.exports = function(eleventyConfig) {
eleventyConfig.setUseGitIgnore(false);

eleventyConfig.addPlugin(EleventyHtmlBasePlugin);

// Copy any .svg or midi file to `_site`, via Glob pattern
// Keeps the same directory structure
eleventyConfig.addPassthroughCopy("songs/**/*.svg");
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/build-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This is a basic workflow to help you get started with Actions

name: Build and Publish to Github pages
inputs:
name:
description: "Artifact name"
required: false
default: "github-pages"
path:
description: "Path of the directory containing the static assets."
required: true
default: "_site/"
retention-days:
description: "Duration after which artifact will expire in days."
required: false
default: "1"
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# container:
# image: codello/lilypond:2.24.1
shell: bash
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2.5.2
with:
node-version: 18.12.0

# Runs a set of commands using the runners shell
- name: Install node dependencies
run: npm ci
- name: Install Lilypond
run: |
wget https://gitlab.com/lilypond/lilypond/-/releases/v2.24.1/downloads/lilypond-2.24.1-linux-x86_64.tar.gz
tar -xzf lilypond-2.24.1-linux-x86_64.tar.gz
- name: Build lilypond artifacts
run: |
cd songs
for dir in */; do
(cd $dir && ../../lilypond-2.24.1/bin/lilypond --svg main.ly)
done
- name: Generate .md files for eleventy
run: npm run build:pre-11ty
- name: Build eleventy
run: npm run build:11ty --pathPrefix=scores-ly
- name: Build artifact archive
run: |
chmod -c -R +rX "$INPUT_PATH" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
env:
INPUT_PATH: ${{ inputs.path }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ runner.temp }}/artifact.tar
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error
1 change: 1 addition & 0 deletions build-lilypond.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
cd songs

for dir in */; do
Expand Down

0 comments on commit 6473192

Please sign in to comment.