Fixed docker build and helm package workflows (invalid tagging) (#46)
* feat: update Helm and Docker workflows to extract chart name and version, and improve tagging logic * fix: add github-actions-ci branch to workflow triggers for Docker and Helm packaging * fix: add helm-package-push.yml to workflow paths for triggering on changes * fix: improve appVersion extraction in Docker workflow and add error handling * fix: enhance appVersion extraction with debugging output and error message * fix: improve error handling for appVersion extraction in Docker and Helm workflows * fix: simplify chart info extraction in Helm workflow and remove error handling * fix: update chart info extraction to use awk for improved parsing * fix: streamline chart info extraction in Helm workflow by removing unnecessary step and directly parsing values * fix: remove newline characters from chart version and name extraction in Helm workflow * Fix newline * Update helm-package-push.yml * Removed claude brainrot * Update helm-package-push.yml
This commit is contained in:
committed by
GitHub
parent
b42bfdffaa
commit
aaaf1d35d6
31
.github/workflows/docker-build-push.yml
vendored
31
.github/workflows/docker-build-push.yml
vendored
@@ -6,6 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
- beta
|
- beta
|
||||||
- dev
|
- dev
|
||||||
|
- github-actions-ci
|
||||||
paths:
|
paths:
|
||||||
- 'src/**'
|
- 'src/**'
|
||||||
- 'helm/Chart.yaml'
|
- 'helm/Chart.yaml'
|
||||||
@@ -45,21 +46,29 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract appVersion from Chart.yaml
|
- name: Extract appVersion from Chart.yaml and determine tags
|
||||||
id: chart_version
|
id: tags
|
||||||
run: |
|
run: |
|
||||||
APP_VERSION=$(grep '^appVersion:' helm/Chart.yaml | awk '{print $2}' | tr -d '"')
|
APP_VERSION=$(grep '^appVersion:' helm/Chart.yaml | awk '{print $2}' | tr -d '"' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||||
echo "version=$APP_VERSION" >> $GITHUB_OUTPUT
|
|
||||||
|
if [ -z "$APP_VERSION" ]; then
|
||||||
|
echo "Error: Could not extract appVersion from Chart.yaml"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
||||||
|
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${APP_VERSION},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||||
|
else
|
||||||
|
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${APP_VERSION}-${{ github.ref_name }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tags=$TAGS" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels)
|
- name: Extract metadata (tags, labels)
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
|
||||||
type=raw,value=${{ steps.chart_version.outputs.version }},enable={{is_default_branch}}
|
|
||||||
type=raw,value=${{ steps.chart_version.outputs.version }}-${{ github.ref_name }},enable=${{ github.ref_name != 'main' }}
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
@@ -67,10 +76,12 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.tags.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
||||||
|
|
||||||
- name: Image digest
|
- name: Image digest
|
||||||
run: echo ${{ steps.meta.outputs.digest }}
|
run: |
|
||||||
|
echo "Image built and pushed with tags:"
|
||||||
|
echo "${{ steps.tags.outputs.tags }}"
|
||||||
|
|||||||
45
.github/workflows/helm-package-push.yml
vendored
45
.github/workflows/helm-package-push.yml
vendored
@@ -6,8 +6,10 @@ on:
|
|||||||
- main
|
- main
|
||||||
- beta
|
- beta
|
||||||
- dev
|
- dev
|
||||||
|
- github-actions-ci
|
||||||
paths:
|
paths:
|
||||||
- 'helm/**'
|
- 'helm/**'
|
||||||
|
- '.github/workflows/helm-package-push.yml'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
release:
|
release:
|
||||||
@@ -39,37 +41,36 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
|
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
- name: Extract version from Chart.yaml
|
- name: Set Helm chart version and package
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}' | tr -d '"')
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Package Helm chart
|
|
||||||
run: |
|
run: |
|
||||||
|
CHART_NAME=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}')
|
||||||
|
BASE_VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}')
|
||||||
|
|
||||||
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
||||||
|
CHART_VERSION="${BASE_VERSION}"
|
||||||
|
else
|
||||||
|
CHART_VERSION="${BASE_VERSION}-${{ github.ref_name }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update Chart.yaml temporarily with the versioned name
|
||||||
|
sed -i "s/^version:.*/version: ${CHART_VERSION}/" ./helm/Chart.yaml
|
||||||
|
|
||||||
|
# Package the helm chart
|
||||||
helm package ./helm
|
helm package ./helm
|
||||||
|
|
||||||
|
echo "CHART_NAME=${CHART_NAME}" >> $GITHUB_ENV
|
||||||
|
echo "CHART_VERSION=${CHART_VERSION}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Push Helm chart to registry
|
- name: Push Helm chart to registry
|
||||||
run: |
|
run: |
|
||||||
CHART_VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}')
|
helm push ${{ env.CHART_NAME }}-${{ env.CHART_VERSION }}.tgz oci://${{ env.REGISTRY }}
|
||||||
CHART_FILE=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}')
|
|
||||||
CHART_PATH="${CHART_FILE}-${CHART_VERSION}.tgz"
|
|
||||||
|
|
||||||
# Determine tag based on branch
|
|
||||||
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
|
||||||
TAG="${{ steps.version.outputs.version }}"
|
|
||||||
helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:$TAG
|
|
||||||
helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:latest
|
|
||||||
else
|
|
||||||
TAG="${{ steps.version.outputs.version }}-${{ github.ref_name }}"
|
|
||||||
helm push "$CHART_PATH" oci://${{ env.REGISTRY }}/$CHART_FILE:$TAG
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Chart pushed
|
- name: Chart pushed
|
||||||
run: |
|
run: |
|
||||||
|
CHART_VERSION=$(grep '^version:' ./helm/Chart.yaml | awk '{print $2}')
|
||||||
CHART_FILE=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}')
|
CHART_FILE=$(grep '^name:' ./helm/Chart.yaml | awk '{print $2}')
|
||||||
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
if [[ "${{ github.ref_name }}" == "main" ]]; then
|
||||||
echo "Chart pushed: $CHART_FILE:${{ steps.version.outputs.version }} and $CHART_FILE:latest"
|
echo "Chart pushed: ${CHART_FILE}:${CHART_VERSION}"
|
||||||
else
|
else
|
||||||
echo "Chart pushed: $CHART_FILE:${{ steps.version.outputs.version }}-${{ github.ref_name }}"
|
echo "Chart pushed: ${CHART_FILE}:${CHART_VERSION}-${{ github.ref_name }}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: krawl-chart
|
name: krawl-chart
|
||||||
description: A Helm chart for Krawl honeypot server
|
description: A Helm chart for Krawl honeypot server
|
||||||
type: application
|
type: application
|
||||||
version: 0.1.3
|
version: 0.1.3
|
||||||
appVersion: "0.1.6"
|
appVersion: 0.1.6
|
||||||
keywords:
|
keywords:
|
||||||
- honeypot
|
- honeypot
|
||||||
- security
|
- security
|
||||||
- krawl
|
- krawl
|
||||||
maintainers:
|
maintainers:
|
||||||
- name: blessedrebus
|
- name: blessedrebus
|
||||||
home: https://github.com/blessedrebus/krawl
|
home: https://github.com/blessedrebus/krawl
|
||||||
sources:
|
sources:
|
||||||
- https://github.com/blessedrebus/krawl
|
- https://github.com/blessedrebus/krawl
|
||||||
|
|||||||
Reference in New Issue
Block a user