Skip to content

Commit

Permalink
Merge pull request #5 from actions-mn/fix/handle-metanorma-1.10-in-v1
Browse files Browse the repository at this point in the history
fix: handle both prior 1.10 and 1.10+ metanorma actions-mn/build-and-publish#15
  • Loading branch information
CAMOBAP authored Jun 9, 2024
2 parents 885ffde + b6a7ac3 commit 89b0c30
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 18 deletions.
58 changes: 51 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- run: |
sudo apt-get install yamllint
yamllint action.yml
test-site-gen:
name: Test ./site-gen/ action on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -27,21 +28,64 @@ jobs:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-iso
path: iso
repository: metanorma/mn-samples-cc
path: cc

- uses: actions-mn/setup@main

- uses: ./
with:
source-path: iso
source-path: cc
config-file: metanorma.yml
agree-to-terms: true

- uses: andstor/file-existence-action@v1
with:
files: iso/_site/index.html
files: cc/_site/index.html

test-before-1-10:
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:1.9.7
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-cc
path: cc

- uses: ./
with:
source-path: cc
agree-to-terms: true
progress: true

- uses: andstor/file-existence-action@v1
with:
files: cc/_site/index.html

test-1-10:
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:1.10.0
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-cc
path: cc

- uses: ./
with:
source-path: cc
agree-to-terms: true

- uses: andstor/file-existence-action@v1
with:
files: cc/_site/index.html
62 changes: 51 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
strict:
description: 'Run metanorma in strict mode'
default: '' # false
progress:
description: 'Display progress related logs'
default: 'false' # false
use-bundler:
description: 'Run in bundler'
default: '' # false
Expand All @@ -35,14 +38,51 @@ inputs:
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${{ inputs.source-path }}
${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \
metanorma site generate . \
${{ inputs.strict && '--strict' || '' }} \
-o ${{ inputs.output-dir }} \
-c ${{ inputs.config-file }} \
${{ inputs.agree-to-terms && '--' || '--no-' }}agree-to-terms \
${{ inputs.install-fonts && '--' || '--no-' }}install-fonts \
${{ inputs.continue-without-fonts && '--' || '--no-' }}continue-without-fonts
- shell: bash
run: |
verlte() {
printf '%s\n' "$1" "$2" | sort -C -V
}
verlt() {
! verlte "$2" "$1"
}
METANORMA_VERSION=$(${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} metanorma --version | head -1 | cut -d' ' -f2)
METANORMA_LEGACY=$(verlt ${METANORMA_VERSION} 1.10.0 && echo "true" || echo "false")
METANORMA_FLAGS=""
if [ "${{ inputs.strict }}" == "true" ]; then
METANORMA_FLAGS+="--strict"
fi
if [ "${{ inputs.progress }}" != "true" ]; then
METANORMA_FLAGS+=" --no-progress"
fi
if [ "${{ inputs.agree-to-terms }}" == "true" ]; then
METANORMA_FLAGS+=" --agree-to-terms"
fi
if [ "${{ inputs.install-fonts }}" != 'true' ]; then
METANORMA_FLAGS+=" --no-install-fonts"
elif [ "$METANORMA_LEGACY" == "true" ]; then
METANORMA_FLAGS+=" --no-no-install-fonts"
else
METANORMA_FLAGS+=" --install-fonts"
fi
if [ "${{ inputs.continue-without-fonts }}" != 'true' ]; then
METANORMA_FLAGS+=" --no-continue-without-fonts"
elif [ "$METANORMA_LEGACY" == "true" ]; then
METANORMA_FLAGS+=" --no-no-continue-without-fonts"
else
METANORMA_FLAGS+=" --continue-without-fonts"
fi
echo "METANORMA_FLAGS=${METANORMA_FLAGS}" >> $GITHUB_ENV
- shell: bash
run: |
cd ${{ inputs.source-path }}
${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \
metanorma site generate . \
-o ${{ inputs.output-dir }} \
-c ${{ inputs.config-file }} \
${{ env.METANORMA_FLAGS }}

0 comments on commit 89b0c30

Please sign in to comment.