File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 1
1
name : Main
2
2
3
- on : [push]
3
+ on :
4
+ push :
5
+ pull_request :
4
6
5
7
jobs :
6
8
print_branch_tag :
16
18
# Use the output/env from the `extract` step
17
19
- name : Print the values
18
20
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 }}"
Original file line number Diff line number Diff line change 1
1
name : Branch Tag Action
2
2
description : Get branch tag and set to ENV
3
3
branding :
4
- icon : ' git-branch'
4
+ icon : ' git-branch'
5
5
color : ' purple'
6
6
inputs :
7
7
ref :
8
8
description : ' The branch or tag ref'
9
9
required : true
10
- default : ${{ github.ref }}
10
+ default : ${{ github.head_ref || github. ref }}
11
11
runs :
12
12
using : docker
13
13
image : Dockerfile
Original file line number Diff line number Diff line change @@ -4,13 +4,15 @@ REF="${1#refs/}"
4
4
BRANCH_NAME=" ${REF# heads/ } "
5
5
TAG_NAME=" ${REF# tags/ } "
6
6
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
11
13
else
12
- BRANCH_TAG=" ${BRANCH_NAME// \/ / -} "
14
+ BRANCH_TAG=" ${BRANCH_NAME// \/ / -} "
13
15
fi
14
16
15
- echo " ::set-env name= BRANCH_TAG:: $BRANCH_TAG "
17
+ echo " BRANCH_TAG= $BRANCH_TAG " >> $GITHUB_ENV
16
18
echo " ::set-output name=branch_tag::$BRANCH_TAG "
You can’t perform that action at this time.
0 commit comments