-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
49 lines (47 loc) · 1.78 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
38
39
40
41
42
43
44
45
46
47
48
49
name: 'actions-build-branch-info'
description: 'Return the active build branch names'
inputs:
exclude-master:
description: 'Set true to exclude returning the master branch ex: for jobs like ios-democ-test'
default: false
latest-rel:
description: 'Set true to return the latest release branch ex: for jobs like l10n-download'
default: false
default-branch:
description: 'Default branch name of the caller repo'
default: master
outputs:
branches-json:
description: "branch names in a JSON list or a single string for latest-rel"
value: ${{ steps.branches.outputs.value }}
runs:
using: "composite"
steps:
- name: Branches
id: branches
shell: bash
run: |
set -x
default_branch="${{ inputs.default-branch }}"
echo "INFO inputs.exclude-master: ${{ inputs.exclude-master }}"
echo "INFO inputs.latest-rel: ${{ inputs.latest-rel }}"
echo "INFO inputs.default-branch: ${default_branch}"
if [[ "${{ inputs.latest-rel }}" == "true" ]]; then
return_str=\"$(echo ${{ env.BRANCH_NAMES }} | tr ' ' '\n' | grep '^rel-' | sort -V | tail -1)\"
else
json_str=""
for item in ${{ env.BRANCH_NAMES }}; do
if [[ "${{ inputs.exclude-master }}" == "true" && "$item" == "master" ]]; then
:
elif [[ "$json_str" == "" ]]; then
json_str="\"$item\""
else
json_str="$json_str, \"$item\""
fi
done
[[ "$default_branch" != "master" ]] && json_str="${json_str/master/$default_branch}"
return_str="[$json_str]"
fi
echo "value=$return_str" >> $GITHUB_OUTPUT
env:
BRANCH_NAMES: "master rel-1.193 rel-1.192"