25
25
contents : read
26
26
security-events : write
27
27
28
- determine_image_tag_and_chart_version :
29
- name : " Determine image tag and chart version from branch name"
30
- runs-on : ubuntu-latest
31
- outputs :
32
- image_tag : ${{ steps.create_image_tag.outputs.image_tag }}
33
- chart_version : ${{ steps.create_image_tag.outputs.chart_version }}
34
- steps :
35
- - id : create_image_tag
36
- run : |
37
- timestamp=`echo $(date +'%Y%m%d-%H%M')`
38
- regex_long='^([[:alpha:]]+?-[[:digit:]]+-[[:digit:]]+)'
39
- regex_short='^([[:alpha:]]+?-[[:digit:]]+)'
40
- if [[ $GITHUB_REF_NAME =~ $regex_long ]]; then
41
- tag="${BASH_REMATCH[1]}"
42
- chart_version="0.0.0-$(echo ${tag} | tr [A-Z] [a-z])-${timestamp}"
43
- elif [[ $GITHUB_REF_NAME =~ $regex_short ]]; then
44
- tag="${BASH_REMATCH[1]}"
45
- chart_version="0.0.0-$(echo ${tag} | tr [A-Z] [a-z])-${timestamp}"
46
- elif [[ "${{ github.ref_name }}" != 'main' ]]; then
47
- tag=""
48
- chart_version=""
49
- else
50
- echo "::error::Couldn't extract ticket from branch $GITHUB_REF_NAME. If not main the branch name should begin alpha-digit or alpha-digit-digit blocks (e.g. SPSH-1234-test-name or release-1-1-optional-text)"
51
- exit 1
52
- fi
53
- echo "image_tag=${tag}" >> "$GITHUB_OUTPUT"
54
- echo "chart_version=${chart_version}" >> "$GITHUB_OUTPUT"
55
-
56
28
build_image_on_push :
57
29
needs :
58
- - determine_image_tag_and_chart_version
30
+ - create_branch_identifier
59
31
name : " Publish image and scan with trivy"
60
32
if : ${{ github.event_name == 'push' }}
61
33
permissions :
67
39
image_name : " dbildungs-iam-keycloak"
68
40
run_trivy_scan : true
69
41
image_tag_generation : ${{ github.ref_name == 'main' && 'commit_hash' || 'specified' }}
70
- image_tag : ${{ github.ref_name == 'main' && '' || needs.determine_image_tag_and_chart_version .outputs.image_tag }}
42
+ image_tag : ${{ github.ref_name == 'main' && '' || needs.create_branch_identifier .outputs.image_tag_from_branch }}
71
43
add_latest_tag : ${{ github.ref_name == 'main' }}
72
44
container_registry : " ghcr.io"
73
45
fail_on_vulnerabilites : false
@@ -100,17 +72,17 @@ jobs:
100
72
101
73
release_helm :
102
74
needs :
103
- - determine_image_tag_and_chart_version
75
+ - create_branch_identifier
104
76
- select_helm_version_generation_and_image_tag_generation
105
77
if : ${{ github.event_name == 'push' && !startsWith(github.ref_name,'dependabot/') }}
106
78
uses : dBildungsplattform/dbp-github-workflows/.github/workflows/chart-release.yaml@7
107
79
secrets : inherit
108
80
with :
109
81
chart_name : dbildungs-iam-keycloak
110
82
image_tag_generation : ${{ needs.select_helm_version_generation_and_image_tag_generation.outputs.SELECT_IMAGE_TAG_GENERATION }}
111
- image_tag : ${{ github.ref_name == 'main' && '' || needs.determine_image_tag_and_chart_version .outputs.image_tag }}
83
+ image_tag : ${{ github.ref_name == 'main' && '' || needs.create_branch_identifier .outputs.image_tag_from_branch }}
112
84
helm_chart_version_generation : ${{ needs.select_helm_version_generation_and_image_tag_generation.outputs.SELECT_HELM_VERSION_GENERATION }}
113
- helm_chart_version : ${{ github.ref_name == 'main' && '' || needs.determine_image_tag_and_chart_version .outputs.chart_version }}
85
+ helm_chart_version : ${{ github.ref_name == 'main' && '' || needs.create_branch_identifier .outputs.chart_version_from_branch }}
114
86
115
87
wait_for_helm_chart_to_get_published :
116
88
needs :
@@ -128,7 +100,7 @@ jobs:
128
100
if : ${{ github.event_name == 'push' && !startsWith(github.ref_name,'dependabot/') }}
129
101
needs :
130
102
- branch_meta
131
- uses : dBildungsplattform/spsh-app-deploy/.github/workflows/convert-branch-name.yml@6
103
+ uses : dBildungsplattform/spsh-app-deploy/.github/workflows/convert-branch-name.yml@DBP-1179-convert-branch-to-image-tag-and-chart-version # todo change back to correct version
132
104
with :
133
105
branch : ${{ needs.branch_meta.outputs.branch }}
134
106
0 commit comments