Skip to content

Commit 802e6bd

Browse files
authored
Merge pull request #2 from nimblehq/chore/update-environment-variable-syntax
Update action to use the new environment files
2 parents fd346bf + eb13d0a commit 802e6bd

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Main
22

3-
on: [push]
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
68
print_branch_tag:
@@ -16,5 +18,5 @@ jobs:
1618
# Use the output/env from the `extract` step
1719
- name: Print the values
1820
run: |
19-
echo "The branch tag is ${{ steps.extract.outputs.branch_tag }}"
20-
echo "or ${{ env.BRANCH_TAG }}"
21+
echo "Output: ${{ steps.extract.outputs.branch_tag }}"
22+
echo "Environment variable: ${{ env.BRANCH_TAG }}"

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Branch Tag Action
22
description: Get branch tag and set to ENV
33
branding:
4-
icon: 'git-branch'
4+
icon: 'git-branch'
55
color: 'purple'
66
inputs:
77
ref:
88
description: 'The branch or tag ref'
99
required: true
10-
default: ${{ github.ref }}
10+
default: ${{ github.head_ref || github.ref }}
1111
runs:
1212
using: docker
1313
image: Dockerfile

entrypoint.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ REF="${1#refs/}"
44
BRANCH_NAME="${REF#heads/}"
55
TAG_NAME="${REF#tags/}"
66

7-
if [[ $BRANCH_NAME == master ]]; then
8-
BRANCH_TAG=latest
9-
elif [[ $TAG_NAME != $REF ]]; then
10-
BRANCH_TAG=$TAG_NAME
7+
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]
8+
then
9+
BRANCH_TAG=latest
10+
elif [[ $TAG_NAME != $REF ]]
11+
then
12+
BRANCH_TAG=$TAG_NAME
1113
else
12-
BRANCH_TAG="${BRANCH_NAME//\//-}"
14+
BRANCH_TAG="${BRANCH_NAME//\//-}"
1315
fi
1416

15-
echo "::set-env name=BRANCH_TAG::$BRANCH_TAG"
17+
echo "BRANCH_TAG=$BRANCH_TAG" >> $GITHUB_ENV
1618
echo "::set-output name=branch_tag::$BRANCH_TAG"

0 commit comments

Comments
 (0)