Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
katybaulch committed Mar 26, 2024
1 parent 2c5cedf commit 7357626
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: "Determine next tag from PR body"
description: "Determine next tag from PR body"

inputs:
body:
PR_BODY:
description: |
Body of pull request if inside a pull request
required: false
# default: ""
number:
PR_NUMBER:
description: |
Pull request number
required: false
Expand All @@ -26,14 +26,14 @@ runs:
- name: Debug
shell: sh
run: |
echo ${{ inputs['body'] }}
echo ${{ inputs['PR_BODY'] }}
echo ${{ inputs['number'] }}
echo ${{ inputs.body }}
echo ${{ inputs.number }}
echo ${{ inputs.body == '' && inputs.number == ''}}
echo ${{ inputs.PR_BODY }}
echo ${{ inputs.PR_NUMBER }}
echo ${{ inputs.PR_BODY == '' && inputs.PR_NUMBER == ''}}
- uses: actions/github-script@v7
if: ${{ inputs.body == '' && inputs.number == '' }}
if: ${{ inputs.PR_BODY == '' && inputs.PR_NUMBER == '' }}
id: get_pr_data
with:
script: |
Expand All @@ -49,18 +49,12 @@ runs:
- uses: fregante/setup-git-user@v2

- name: Determine new tag version from PR event
if: ${{ inputs.body != '' && inputs.number != ''}}
if: ${{ inputs.PR_BODY != '' && inputs.PR_NUMBER != ''}}
shell: sh
id: determine_next_tag_from_pr_event
# User controlled input needs to be santitised beforehand e.g., by adding an
# intermediate env var to prevent the workflow being exposed to a critical
# command injection attack
env:
PR_BODY: "${{ inputs.body }}"
PR_NUMBER: "${{ inputs.number }}"
run: |
echo "Attempting to auto-tag merge commit2"
script_output=$("${{ github.action_path }}/auto-tag.sh" "${PR_BODY}" "${PR_NUMBER}")
echo "Checking whether tag version can be determined from PR body..."
script_output=$("${{ github.action_path }}/auto-tag.sh" "${{ inputs.PR_BODY }}" "${{ inputs.PR_NUMBER }}")
if $? != 0; then
exit 1
fi
Expand All @@ -69,18 +63,18 @@ runs:
echo "new_tag=${new_tag}" >> "$GITHUB_OUTPUT"
- name: Determine new tag version
if: ${{ inputs.body == '' && inputs.number == '' }}
if: ${{ inputs.PR_BODY == '' && inputs.PR_NUMBER == '' }}
shell: sh
id: determine_next_tag
# User controlled input needs to be santitised beforehand e.g., by adding an
# intermediate env var to prevent the workflow being exposed to a critical
# command injection attack
env:
PR_BODY: "${{ fromJson(steps.get_pr_data.outputs.result).body }}"
PR_NUMBER: "${{ fromJson(steps.get_pr_data.outputs.result).number }}"
PR_BODY_FROM_JSON: "${{ fromJson(steps.get_pr_data.outputs.result).body }}"
PR_NUMBER_FROM_JSON: "${{ fromJson(steps.get_pr_data.outputs.result).number }}"
run: |
echo "Attempting to auto-tag merge commit"
script_output=$("${{ github.action_path }}/auto-tag.sh" "${PR_BODY}" "${PR_NUMBER}")
script_output=$("${{ github.action_path }}/auto-tag.sh" "${PR_BODY_FROM_JSON}" "${PR_NUMBER_FROM_JSON}")
if $? != 0; then
exit 1
fi
Expand Down

0 comments on commit 7357626

Please sign in to comment.