Skip to content

Make title link to home page #341

Make title link to home page

Make title link to home page #341

Workflow file for this run

# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build
on:
push:
paths:
- '**.vue'
- '**.ts'
- '**.tsx'
- '!**.test.ts'
- '**.js'
- '**.jsx'
- '**.json'
- '**.mscz'
- '**.conf'
- '**.go'
- 'Dockerfile'
- '*.Dockerfile'
- '.Dockerignore'
- '**/build-vue.yml'
pull_request:
branches: [ main, dev ]
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: fysiksektionen/sangbok-html
jobs:
##
## Build zip file to export
##
build:
runs-on: ubuntu-latest
name: Build vue
needs: sheet-music
strategy:
fail-fast: false
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install packages
run: npm ci
- name: Fetch sheet music artifacts
uses: actions/download-artifact@v3
with:
name: music-svgs
path: public/msvg
- name: Unpack sheet music artifacts
working-directory: public/msvg
run: mv svgs.json ../../src/assets/msvgs.json
- name: build
run: npx vite build
- name: Archive production artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.node-version == '20.x' }}
with:
name: dist-node-${{ matrix.node-version }}
path: |
dist
##
## Sheet music generation
##
sheet-music:
runs-on: ubuntu-latest
name: Generate sheet music resources
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'npm'
- name: Install svgo
run: npm install -g svgo
- name: Install MuseScore 3
run: sudo apt-get update && sudo apt-get install musescore3
- name: Unpack cached svg:s
run: rm -rf svg && tar -xJf svg.tar.lzma
working-directory: ./music
- name: Convert mscz to compressed svg:s (from cache)
working-directory: ./music
run: ./convert.sh --compress --no-move
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/actions-dev' }}
- name: Convert mscz to compressed svg:s (from scratch)
working-directory: ./music
run: ./convert.sh --compress --no-move --force-on-change
if: ${{ github.ref == 'refs/heads/main' }}
- name: Convert mscz to compressed svg:s (workflow testing)
working-directory: ./music
run: ./convert.sh --compress --no-move --force-cache-regeneration
if: ${{ github.ref == 'refs/heads/actions-dev' }}
- name: Compute hashes
working-directory: ./music
run: sha1sum mscz/*.mscz
- name: Perpare for export
working-directory: ./music
run: cp svgs.json svg
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: music-svgs
path: music/svg
- name: Push new cache to repo
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add music/svg.tar.lzma music/mscz.sha1 music/svgs.json
git commit -m "Automatic msvg cache update ($(head -c 8 music/mscz.sha1))" --author "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | exit 0
git push
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/actions-dev' }}
# TODO: git commit exit codes are overridden above. This is most commonly done to prevent the workflow from crashing due to empty commits. It may, however, be a source of bugs if git commit crashes for some other reason.
##
## Docker build
##
docker:
runs-on: ubuntu-latest
name: Build Docker containers
needs: sheet-music
strategy:
fail-fast: false
matrix:
variant: [default, gz, gz-br]
include:
- variant: default
compression: semi-redundant gzip/brotli
server: nginx
- variant: gz
suffix: -nginx-gz
compression: gzip
server: nginx
- variant: gz-br
suffix: -nginx-gz-br
compression: redundant gzip/brotli
server: nginx
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch sheet music artifacts
uses: actions/download-artifact@v3
with:
name: music-svgs
path: public/msvg
- name: Unpack sheet music artifacts
working-directory: public/msvg
run: mv svgs.json ../../src/assets/msvgs.json
# Login against a Docker registry except on PR(https://github.com/docker/login-action)
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker (https://github.com/docker/metadata-action)
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=edge,branch=dev
type=ref,event=branch
flavor: |
suffix=${{ matrix.suffix }}
- name: Build and push Docker image (${{ matrix.server }} with ${{ matrix.compression }} precompression)
uses: docker/build-push-action@v5
with:
file: docker/${{ matrix.server }}/${{ matrix.variant }}.Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}