forked from centreon/centreon-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (59 loc) · 1.89 KB
/
Copy pathget-environment.yml
File metadata and controls
66 lines (59 loc) · 1.89 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
on:
workflow_call:
inputs:
version_file:
required: false
type: string
outputs:
stability:
description: "branch stability (stable, testing, unstable, canary)"
value: ${{ jobs.get-version.outputs.stability }}
version:
description: "version"
value: ${{ jobs.get-version.outputs.version }}
release:
description: "release number"
value: ${{ jobs.get-version.outputs.release }}
jobs:
get-version:
runs-on: ubuntu-22.04
outputs:
stability: ${{ steps.get_environment.outputs.stability }}
version: ${{ steps.get_environment.outputs.version }}
release: ${{ steps.get_environment.outputs.release }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- id: get_environment
run: |
if [[ -z "$GITHUB_HEAD_REF" ]]; then
BRANCHNAME="$GITHUB_REF_NAME"
else
BRANCHNAME="$GITHUB_HEAD_REF"
fi
case "$BRANCHNAME" in
develop)
STABILITY="unstable"
;;
release* | hotfix*)
STABILITY="testing"
;;
master)
STABILITY="stable"
;;
*)
STABILITY="canary"
;;
esac
echo "stability=$STABILITY" >> $GITHUB_OUTPUT
if [[ "${{ inputs.version_file }}" == "" ]]; then
VERSION=$(date '+%Y%m%d')
elif [[ "${{ inputs.version_file }}" == */*.yaml ]]; then
VERSION=$(grep 'version: ' ${{ inputs.version_file }} | cut -d' ' -f2 | tr -d '"')
else
VERSION=$(grep VERSION ${{ inputs.version_file }} | cut -d "'" -f 2)
fi
echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT
RELEASE=$(date '+%H%M%S')
echo "release=$(echo $RELEASE)" >> $GITHUB_OUTPUT
shell: bash