-
Notifications
You must be signed in to change notification settings - Fork 19
/
action.yml
37 lines (37 loc) · 1.21 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Determine Branch Tag
description: Determine the tag to be used for e.g. building Docker images
inputs:
dir:
description: The root directory for the sources to inspect
default: ${{ github.workspace }}
required: false
use_base_for_pr:
description: Should the base branch be used for pull requests
default: no
required: false
outputs:
tag:
description: The tag derived from the branch information
value: ${{ steps.determine-tag.outputs.tag }}
created:
description: The timestamp for when the tag was created
value: ${{ steps.determine-tag.outputs.created }}
runs:
using: "composite"
steps:
- shell: bash
id: determine-tag
run: |
if [[ -z $GITHUB_BASE_REF ]]; then
# On master/stable branches.
branch=${GITHUB_REF#refs/heads/}
elif [[ "${{ inputs.use_base_for_pr }}" == "yes" ]]; then
# Use base branch.
branch=$GITHUB_BASE_REF
else
# On pull request branches.
branch=pr-$(git describe --always --match '' --abbrev=7)
fi
branch=${branch//\//-}
echo "tag=$(echo ${branch})" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT