Skip to content

Commit

Permalink
fix: Fix output in action
Browse files Browse the repository at this point in the history
Seems to be that we can't rely on the `env` context for the value of composite
action outputs... oh well...

To fix, added a step that sets the `branch-name` output based on the env var set
in the previous steps.
  • Loading branch information
jskrzypek committed Jan 27, 2022
1 parent 37e516b commit a421672
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- name: Set Git Branch
id: set-git-branch
uses: jskrzypek/[email protected]
uses: jskrzypek/[email protected].1
- name: Check that env var was set
id: test-env-var
run: |
Expand Down
13 changes: 8 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ branding:
outputs:
branch-name:
description: "The branch name"
value: ${{ env.GIT_BRANCH }}
value: ${{ steps.set-output.outputs.branch-name }}
runs:
using: "composite"
steps:
- name: Set Git branch name on PR
- name: Set Git Branch Name for PR Events
id: branch-name-from-pr
if: |-
github.event_name == 'pull_request'
|| github.event_name == 'pull_request_target'
run: |
echo "GIT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "::set-output name=branch-name::${{ github.head_ref }}"
shell: bash
- name: Set Env Vars on non-PR branch events
- name: Set Git Branch Name for non-PR Branch Events
id: branch-name-from-non-pr
if: |-
github.event_name != 'pull_request'
&& github.event_name != 'pull_request_target'
&& github.ref_type == 'branch'
run: |
echo "GIT_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
echo "::set-output name=branch-name::${{ github.head_ref }}"
shell: bash
- name: Set output from env var
id: set-output
run: |
echo "::set-output name=branch-name::${{ env.GIT_BRANCH }}"
shell: bash

0 comments on commit a421672

Please sign in to comment.