Skip to content

Commit

Permalink
calculate the output filename based on the input (#171)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chrisfenner authored Sep 10, 2024
1 parent 02e2bb4 commit 3ed36b6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR
name: pull_request

on:
pull_request:
Expand Down Expand Up @@ -51,4 +51,3 @@ jobs:
container-version: latest
input: guide.tcg
workflow: pr
output: guide
3 changes: 1 addition & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -70,4 +70,3 @@ jobs:
container-version: latest
input: guide.tcg
workflow: push
output: guide
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -70,4 +70,3 @@ jobs:
container-version: latest
input: guide.tcg
workflow: release
output: guide
25 changes: 15 additions & 10 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()

0 comments on commit 3ed36b6

Please sign in to comment.