Skip to content

Commit

Permalink
fix(GITHUB_REF_NAME): use the github default variable instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rlespinasse committed Apr 9, 2022
1 parent aa95092 commit 67d56e0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/v4-tests-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
name: "[v4] Test and Release"
on: [push, pull_request]
jobs:
print-datasource:
name: "Print Datasource"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Print datasource
run: |
echo "github.repository : ${{ github.repository }}"
echo "GITHUB_REF : $GITHUB_REF"
echo "GITHUB_HEAD_REF : $GITHUB_HEAD_REF"
echo "GITHUB_BASE_REF : $GITHUB_BASE_REF"
echo "GITHUB_REF_NAME : $GITHUB_REF_NAME"
echo "github.event.ref : ${{ github.event.ref }}"
echo "GITHUB_SHA : $GITHUB_SHA"
echo "GITHUB_EVENT_PULL_REQUEST_HEAD_SHA : ${{ github.event.pull_request.head.sha }}"
check-v3compatibility:
name: "Check v3 compatibility"
strategy:
Expand All @@ -11,14 +30,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Load using v4.x with prefix
uses: ./
with:
prefix: V4_
short-length: 8

- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Validate // Partial variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
Expand Down Expand Up @@ -96,14 +117,16 @@ jobs:
with:
path: this-action
ref: ${{ github.ref }}
- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Load using v4.x with prefix
uses: ./this-action
with:
prefix: V4_
short-length: 8

- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Validate // Short SHA variables
run: |
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
Expand All @@ -120,6 +143,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load using v4.x
uses: ./

Expand Down Expand Up @@ -200,14 +224,16 @@ jobs:
with:
path: this-action
ref: ${{ github.ref }}
- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Load using v4.x with prefix
uses: ./this-action
with:
prefix: V4_
short-length: 8

- name: Load using v3.x
uses: rlespinasse/[email protected]

- name: Short SHA variables
run: |
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
Expand Down
14 changes: 5 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ runs:
key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REF_NAME
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}

# Specific values
- uses: rlespinasse/[email protected]
Expand All @@ -57,15 +62,6 @@ runs:
slug-maxlength: ${{ inputs.slug-maxlength }}

# Calculated values
- id: get-github-ref-name
run: echo "::set-output name=github-ref-name::$(echo "${{ github.head_ref || github.ref }}" | cut -d/ -f3)"
shell: bash
- uses: rlespinasse/[email protected]
with:
key: GITHUB_REF_NAME
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- id: get-github-repository-owner-part
run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)"
shell: bash
Expand Down

0 comments on commit 67d56e0

Please sign in to comment.