From 0dc403f63f9b29dca2a02bb2c608ebdeb8a48a76 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Sun, 28 Jul 2024 18:31:28 +0200 Subject: [PATCH 1/3] feat: add timestamps input #4 --- .github/workflows/test.yml | 5 +++++ action.yml | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7edbaff..3e5a58a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,6 +65,10 @@ jobs: - image: metanorma/metanorma:1.10.0 install-fonts: false continue-without-fonts: true + - image: metanorma/metanorma:1.9.7 + install-fonts: true + continue-without-fonts: false + timestamps: true container: image: ${{ matrix.image }} steps: @@ -81,6 +85,7 @@ jobs: agree-to-terms: true install-fonts: ${{ matrix.install-fonts }} continue-without-fonts: ${{ matrix.continue-without-fonts }} + timestamps: ${{ matrix.timestamps }} - uses: andstor/file-existence-action@v3 with: diff --git a/action.yml b/action.yml index b0ce316..1fd40fd 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,9 @@ inputs: use-bundler: description: 'Run in bundler' default: '' # false + timestamps: + description: 'Do timestamps to logs' + default: '' # false # stylesheet: # description: 'Stylesheet file path for rendering HTML page' # template-dir: @@ -77,6 +80,10 @@ runs: METANORMA_FLAGS+=" --no-continue-without-fonts" fi + if [ "${{ inputs.timestamps }}" == "true" ]; then + METANORMA_FLAGS+=" | ts '[%m-%d-%Y %H:%M:%.S]'" + fi + echo "METANORMA_FLAGS=${METANORMA_FLAGS}" >> $GITHUB_ENV - shell: bash From 8a7818694cafd0f179fbb044ee2b78614a854e15 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 29 Jul 2024 10:45:44 +0200 Subject: [PATCH 2/3] fix: handle the case when ts is not installed --- action.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1fd40fd..77c4649 100644 --- a/action.yml +++ b/action.yml @@ -81,13 +81,19 @@ runs: fi if [ "${{ inputs.timestamps }}" == "true" ]; then - METANORMA_FLAGS+=" | ts '[%m-%d-%Y %H:%M:%.S]'" + METANORMA_FLAGS+=" | mn_timestamp" fi echo "METANORMA_FLAGS=${METANORMA_FLAGS}" >> $GITHUB_ENV - shell: bash run: | + mn_timestamp() { + while IFS= read -r line; do + echo "$(date +'%Y-%m-%d %H:%M:%S') - $line" + done + } + cd ${{ inputs.source-path }} ${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \ metanorma site generate . \ From 867f645f9ac95ea06613a5887ed29664654e6f13 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 29 Jul 2024 11:25:41 +0200 Subject: [PATCH 3/3] fix: use separate mn_ts script instead function --- action.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 77c4649..a2f6d4e 100644 --- a/action.yml +++ b/action.yml @@ -81,19 +81,18 @@ runs: fi if [ "${{ inputs.timestamps }}" == "true" ]; then - METANORMA_FLAGS+=" | mn_timestamp" + echo '#!/bin/bash + while IFS= read -r line; do + echo $(date +"%Y-%m-%d %H:%M:%S") - $line + done' > /usr/local/bin/mn_ts.sh + chmod +x /usr/local/bin/mn_ts.sh + METANORMA_FLAGS+=" | mn_ts.sh" fi echo "METANORMA_FLAGS=${METANORMA_FLAGS}" >> $GITHUB_ENV - shell: bash run: | - mn_timestamp() { - while IFS= read -r line; do - echo "$(date +'%Y-%m-%d %H:%M:%S') - $line" - done - } - cd ${{ inputs.source-path }} ${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \ metanorma site generate . \