diff --git a/action.yaml b/action.yaml index dd04c51..3c143cf 100644 --- a/action.yaml +++ b/action.yaml @@ -40,22 +40,45 @@ runs: - run: sudo apt-get install -y kramdown weasyprint imagemagick ghostscript shell: bash - name: Render Markdown from configured backlog queries - run: python backlogger/backlogger.py ${{ inputs.config }} ${{ inputs.args }} + run: | + python backlogger/backlogger.py ${{ inputs.config }} ${{ inputs.args }} + echo "BACKLOG_STATUS=$?" >> "$GITHUB_ENV" env: REDMINE_API_KEY: ${{ inputs.REDMINE_API_KEY }} shell: bash + - name: Define variables + run: | + org=${{ github.repository_owner }} + repo=$(cut -f2 -d/ <<<${{ github.repository }}) + [ "${{ github.event_name }}" == pull_request ] && extra="/pr-preview/pr-${{ github.event.number }}" + preview="preview_$(date +%s).png" + echo "PREVIEW_NAME=$preview" >> "$GITHUB_ENV" + echo "PREVIEW_URL=https://$org.github.io/$repo$extra/$preview" >> "$GITHUB_ENV" + if [ "${{ env.BACKLOG_STATUS }}" -eq 0 ]; then + color="#55cc33" + else + color="#cc3333" + fi + echo "STATUS_COLOR=$color" >> "$GITHUB_ENV" + shell: bash - name: Render HTML run: | mkdir -p ${{ inputs.folder }} cd ${{ inputs.folder }} - cat ../backlogger/head.html >index.html - kramdown ../index.md >>index.html - sed s@GITHUB_REPOSITORY@${{ github.repository }}@g ../backlogger/foot.html >>index.html + cat ../backlogger/head.html > index.html + kramdown ../index.md >> index.html + cat ../backlogger/foot.html >> index.html + sed -i \ + -e "s@STATUS_COLOR@${{ env.STATUS_COLOR }}@g" \ + -e "s@GITHUB_REPOSITORY@${{ github.repository }}@g" \ + -e "s@PREVIEW_IMAGE_URL@${{ env.PREVIEW_URL }}@g" \ + -e "s@WORKFLOW_NAME@${{ github.workflow }}@g" \ + index.html shell: bash - name: Render PNG preview run: | cd ${{ inputs.folder }} # Remove workaround for already fixed CVE-2018-16509 sudo sed -i '/rights="none" pattern="PDF"/d' /etc/ImageMagick-6/policy.xml - weasyprint index.html - | convert - -trim preview.png + weasyprint index.html - | convert - -trim ${{ env.PREVIEW_NAME }} shell: bash diff --git a/head.html b/head.html index 355233a..b22bfa5 100644 --- a/head.html +++ b/head.html @@ -1,11 +1,15 @@ - +