d57f56f196
CI Git-Pages Main / Load git-pages.gitea-env.conf to pipeline env (push) Successful in 22s
CI Main / Load example-gitea-env.conf to pipeline env (push) Successful in 24s
CI Git-Pages Main / Check existing artifact (push) Successful in 22s
CI Main / Check existing artifact (push) Successful in 22s
ci-helm-build-push Helm chart 0.1.2
CI Git-Pages Main / Build & Push Helm chart (push) Successful in 42s
CI Git-Pages Main / Report Summary (push) Successful in 5s
acc-tests Cucumber test report
CI Main / Cucumber tests (push) Successful in 1m11s
ci-docker-build-push Docker build & push 0.2.16 OK
CI Main / Build & Push Docker (push) Successful in 31s
CI Main / Report Summary (push) Successful in 6s
CI Main / Move provider version tag (push) Successful in 12s
unit-tests Bats test report
CI Main / Bats tests (push) Successful in 1m55s
Co-authored-by: moilanik <niko.moilanen@tietoevry.com> Reviewed-on: #30
105 lines
3.3 KiB
YAML
105 lines
3.3 KiB
YAML
name: Helm Build & Push
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
env_json:
|
|
required: true
|
|
type: string
|
|
version:
|
|
required: true
|
|
type: string
|
|
chart_path:
|
|
required: false
|
|
type: string
|
|
default: '.'
|
|
secrets:
|
|
GITEA_TOKEN:
|
|
required: true
|
|
HELM_USER:
|
|
required: false
|
|
HELM_PASSWORD:
|
|
required: true
|
|
|
|
env:
|
|
GITEA_API_URL: ${{ fromJson(inputs.env_json).GITEA_API_URL }}
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
HELM_REGISTRY: ${{ fromJson(inputs.env_json).HELM_REGISTRY || '' }}
|
|
HELM_UI_URL: ${{ fromJson(inputs.env_json).HELM_UI_URL || '' }}
|
|
GIT_TAG_PREFIX: ${{ fromJson(inputs.env_json).GIT_TAG_PREFIX || '' }}
|
|
CHART_PATH: ${{ inputs.chart_path }}
|
|
VERSION: ${{ inputs.version }}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-push:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: alpine/helm:3.19.0
|
|
steps:
|
|
- name: Install Node.js for actions/checkout
|
|
# COMPROMISE: Requires internet access.
|
|
# Does NOT work in air-gapped environments.
|
|
# Replace with a custom image (e.g., extending alpine/helm + nodejs) if needed.
|
|
run: apk add --no-cache nodejs
|
|
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
repository: niko/gitea-ci-library
|
|
path: .ci
|
|
|
|
- name: Package Helm chart
|
|
run: |
|
|
helm dependency update "${CHART_PATH}"
|
|
helm package "${CHART_PATH}" \
|
|
--version "${VERSION}" \
|
|
--app-version "${VERSION}" \
|
|
--destination /tmp/helm-packages
|
|
|
|
- name: Push to OCI registry
|
|
env:
|
|
HELM_USER: ${{ secrets.HELM_USER || github.actor }}
|
|
HELM_PASSWORD: ${{ secrets.HELM_PASSWORD }}
|
|
run: |
|
|
REGISTRY="${HELM_REGISTRY:?HELM_REGISTRY not set in env.conf}"
|
|
echo "$HELM_PASSWORD" | helm registry login "${REGISTRY}" \
|
|
-u "$HELM_USER" \
|
|
--password-stdin
|
|
helm push /tmp/helm-packages/*.tgz "oci://${REGISTRY}"
|
|
helm registry logout "${REGISTRY}"
|
|
|
|
- name: Report status with UI link
|
|
if: success() && env.HELM_UI_URL != ''
|
|
run: |
|
|
CHART_NAME=$(grep '^name:' "${CHART_PATH}/Chart.yaml" | awk '{print $2}')
|
|
UI_URL="${HELM_UI_URL}/${CHART_NAME}/${VERSION}"
|
|
bash .ci/scripts/report-status.sh success "Helm chart ${VERSION}" ci-helm-build-push "" "$UI_URL"
|
|
|
|
tag-commit:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-push]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Create git tag
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
SERVER_URL: ${{ gitea.server_url }}
|
|
RUN_NUMBER: ${{ github.run_number }}
|
|
SHA: ${{ github.sha }}
|
|
run: |
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
|
"$SERVER_URL/api/v1/repos/${{ github.repository }}/tags" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${GIT_TAG_PREFIX}${VERSION}\", \"message\": \"Build #$RUN_NUMBER\", \"target\": \"$SHA\"}")
|
|
|
|
if [ "$HTTP_CODE" = "201" ] || [ "$HTTP_CODE" = "409" ]; then
|
|
exit 0
|
|
else
|
|
exit 1
|
|
fi
|