Skip to content

Commit

Permalink
fix: handle both prior 1.10 and 1.10+ metanorma actions-mn/build-and-…
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Jun 9, 2024
1 parent 885ffde commit c83d8f5
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 13 deletions.
48 changes: 46 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- 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,9 +28,9 @@ 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
Expand All @@ -45,3 +46,46 @@ jobs:
- uses: andstor/file-existence-action@v1
with:
files: iso/_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:
token: ${{ secrets.GITHUB_TOKEN }}
source-path: cc
agree-to-terms: 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
63 changes: 52 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,52 @@ 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)
verlt ${METANORMA_VERSION} 1.10.0
METANORMA_LEGACY=$?
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 -eq 0 ]; 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 -eq 0 ]; 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 c83d8f5

Please sign in to comment.