NorgesFjelde #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Build and Publish to Github pages | |
env: | |
INPUT_PATH: "_site/" | |
# 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 | |
# 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 && | |
if test -f "main.ly"; then | |
../../lilypond-2.24.1/bin/lilypond --svg main.ly | |
fi | |
) | |
done | |
- name: Generate .md files for eleventy | |
run: npm run build:pre-11ty | |
- name: Build eleventy | |
run: npm run build:11ty | |
- 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 \ | |
. | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "github-pages" | |
path: ${{ runner.temp }}/artifact.tar | |
retention-days: 1 | |
if-no-files-found: error | |
deploy: | |
needs: build | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |