diff --git a/.github/actions/bundle-gh-page/action.yml b/.github/actions/bundle-gh-page/action.yml index 9c4b98b..4848532 100644 --- a/.github/actions/bundle-gh-page/action.yml +++ b/.github/actions/bundle-gh-page/action.yml @@ -4,8 +4,7 @@ runs: using: "composite" steps: - name: ↔ Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + uses: ./.github/actions/extract-branch id: extract_branch - name: ➕ Create temp or public dir run: | diff --git a/.github/actions/extract-branch/action.yml b/.github/actions/extract-branch/action.yml new file mode 100644 index 0000000..c16cabf --- /dev/null +++ b/.github/actions/extract-branch/action.yml @@ -0,0 +1,27 @@ +--- +name: "Extract branch name" +description: "Extract branch name based on pr or push" +outputs: + branch-name: + description: "Branch name" + value: ${{ steps.branch-name.outputs.branch-name }} +runs: + using: "composite" + steps: + - name: ⏬ Get branch name + uses: actions/github-script@v6 + id: get-branch-name + with: + result-encoding: string + script: | + return ( + context?.payload?.pull_request?.head?.ref || + context?.payload?.ref || "" + ).replace("refs/heads/",""); + + - name: 🪑 Set output + id: branch-name + run: echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT + shell: bash + env: + BRANCH_NAME: ${{steps.get-branch-name.outputs.result}}