From 3ed36b68f12f2a349bd88aa28f0e9ec722c10e03 Mon Sep 17 00:00:00 2001 From: Chris Fenner Date: Tue, 10 Sep 2024 09:58:27 -0700 Subject: [PATCH] calculate the output filename based on the input (#171) * calculate the output filename based on the input * lowercase; also use quotes * print output filename when calculating * reference output file name in upload step * update pr and release workflow to use the calculated name --- .github/workflows/pr.yml | 3 +-- .github/workflows/push.yml | 3 +-- .github/workflows/release.yml | 3 +-- .github/workflows/render.yml | 25 +++++++++++++++---------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d0c909b..f84074c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: PR +name: pull_request on: pull_request: @@ -51,4 +51,3 @@ jobs: container-version: latest input: guide.tcg workflow: pr - output: guide diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9c44597..aa3379e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,5 +1,5 @@ # Build and publish the container and use it to render the PDF for pushes to main. -name: Push +name: push on: push: @@ -70,4 +70,3 @@ jobs: container-version: latest input: guide.tcg workflow: push - output: guide diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9e0320..c09ccc3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ # Build, publish, and tag the container and use it to render the PDF for releases. -name: build and publish +name: release on: release: @@ -70,4 +70,3 @@ jobs: container-version: latest input: guide.tcg workflow: release - output: guide diff --git a/.github/workflows/render.yml b/.github/workflows/render.yml index 7a797ba..052d7cf 100644 --- a/.github/workflows/render.yml +++ b/.github/workflows/render.yml @@ -1,7 +1,7 @@ # Reusable workflow to render the spec for a variety of purposes. # https://docs.github.com/en/actions/using-workflows/reusing-workflows -name: Render Markdown +name: render on: workflow_call: @@ -23,10 +23,6 @@ on: description: the workflow to run ('pr', 'push', 'release') required: true type: string - output: - description: the base name for output files - required: true - type: string jobs: render: @@ -35,6 +31,15 @@ jobs: image: ${{ inputs.container }}:${{ inputs.container-version }} name: Render steps: + # Use the input file name (no extension) as the base filename for the output + - name: Calculate output file name + id: gen_output_name + run: | + filename=$(basename ${{ inputs.input }}) + filename="${filename%.*}" + echo OUTPUT_FILENAME="${filename}" >> "$GITHUB_OUTPUT" + echo output filename: ${filename} + - name: Checkout uses: actions/checkout@v3 with: @@ -67,7 +72,7 @@ jobs: uses: ./.github/actions/render with: input-md: ${{ inputs.input }} - output-basename: ${{ inputs.output }} + output-basename: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }} pdf: true diffbase: "${{ github.event.pull_request.base.sha }}" pr-number: "${{ github.event.number }}" @@ -78,7 +83,7 @@ jobs: uses: ./.github/actions/render with: input-md: ${{ inputs.input }} - output-basename: ${{ inputs.output }} + output-basename: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }} pdf: true # Upload the PDF to the release in 'release' mode @@ -87,7 +92,7 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ inputs.output }}.*.pdf + file: ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.pdf tag: ${{ github.ref }} overwrite: true file_glob: true @@ -97,12 +102,12 @@ jobs: with: name: PDF path: | - ${{ inputs.output }}.*.pdf + ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.pdf if: always() - name: Upload logs uses: actions/upload-artifact@master with: name: Logs path: | - ${{ inputs.output }}.*.log + ${{ steps.gen_output_name.outputs.OUTPUT_FILENAME }}.*.log if: always()