Skip to content

Commit b7cb6a6

Browse files
committed
use reusable workflow for tag and version
1 parent a7c689b commit b7cb6a6

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

.github/workflows/image-and-helm-publish-check-deploy-on-push-scheduled.yml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,9 @@ jobs:
2525
contents: read
2626
security-events: write
2727

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-
5628
build_image_on_push:
5729
needs:
58-
- determine_image_tag_and_chart_version
30+
- create_branch_identifier
5931
name: "Publish image and scan with trivy"
6032
if: ${{ github.event_name == 'push' }}
6133
permissions:
@@ -67,7 +39,7 @@ jobs:
6739
image_name: "dbildungs-iam-keycloak"
6840
run_trivy_scan: true
6941
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 }}
7143
add_latest_tag: ${{ github.ref_name == 'main' }}
7244
container_registry: "ghcr.io"
7345
fail_on_vulnerabilites: false
@@ -100,17 +72,17 @@ jobs:
10072
10173
release_helm:
10274
needs:
103-
- determine_image_tag_and_chart_version
75+
- create_branch_identifier
10476
- select_helm_version_generation_and_image_tag_generation
10577
if: ${{ github.event_name == 'push' && !startsWith(github.ref_name,'dependabot/') }}
10678
uses: dBildungsplattform/dbp-github-workflows/.github/workflows/chart-release.yaml@7
10779
secrets: inherit
10880
with:
10981
chart_name: dbildungs-iam-keycloak
11082
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 }}
11284
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 }}
11486

11587
wait_for_helm_chart_to_get_published:
11688
needs:
@@ -128,7 +100,7 @@ jobs:
128100
if: ${{ github.event_name == 'push' && !startsWith(github.ref_name,'dependabot/') }}
129101
needs:
130102
- 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
132104
with:
133105
branch: ${{ needs.branch_meta.outputs.branch }}
134106

0 commit comments

Comments
 (0)