ci(pipeline): update helm package command for versioning #349
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pipeline | |
on: | |
push: | |
branches: | |
- '**' # Matches all branches | |
pull_request: | |
branches: | |
- '**' # Matches all branches | |
workflow_dispatch: | |
inputs: | |
force_build: | |
description: 'Forces a build even if no changes are detected' | |
required: true | |
default: 'false' | |
force_publish: | |
description: 'Forces a publish even if no changes are detected' | |
required: true | |
default: 'false' | |
concurrency: | |
group: pipeline-${{ github.ref_name }} | |
cancel-in-progress: true | |
env: | |
containerImage: "kubernetes-reflector" | |
dockerHubContainerImageRepository: "emberstack" | |
ghcrContainerImageRepository: "ghcr.io/emberstack" | |
jobs: | |
discovery: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: read | |
outputs: | |
pathsFilter_src: ${{ steps.pathsFilter.outputs.src }} | |
gitVersion_SemVer: ${{ steps.gitversion.outputs.GitVersion_SemVer }} | |
gitVersion_AssemblySemFileVer: ${{ steps.gitversion.outputs.GitVersion_AssemblySemFileVer }} | |
requiresBuild: ${{ steps.requires_build.outputs.result }} | |
requiresBuildPush: ${{ steps.requires_build_push.outputs.result }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: tools - dotnet - install | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.x' | |
- name: tools - gitversion - install | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
preferLatestVersion: true | |
- name: gitversion - execute | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
configFilePath: GitVersion.yaml | |
- name: tools - detect changes | |
id: pathsFilter | |
uses: dorny/paths-filter@v3 | |
with: | |
base: ${{ github.ref }} | |
filters: | | |
src: | |
- 'src/**' | |
- name: evaluate - requires_build | |
id: requires_build | |
run: | | |
if [ "${{ steps.pathsFilter.outputs.src }}" = "true" ] || \ | |
[ "${{ github.event.inputs.force_build }}" = "true" ] || \ | |
[ "${{ github.event.inputs.force_publish }}" = "true" ]; then | |
result=true | |
else | |
result=false | |
fi | |
echo "result=$result" >> $GITHUB_OUTPUT | |
- name: evaluate - requires_build_push | |
id: requires_build_push | |
run: | | |
if [ "${{ steps.requires_build.outputs.result }}" = "true" ]; then | |
result=true | |
else | |
result=false | |
fi | |
echo "result=$result" >> $GITHUB_OUTPUT | |
build: | |
name: build | |
# if: ${{ needs.discovery.outputs.requiresBuild == 'true' }} | |
needs: [discovery] | |
runs-on: ubuntu-latest | |
env: | |
# operator_credentials: ${{ needs.discovery.outputs.operator_credentials }} | |
# image_registry: ${{ needs.discovery.outputs.image_registry }} | |
# build_push: ${{ needs.discovery.outputs.build_push }} | |
# build_configuration: ${{ needs.discovery.outputs.build_configuration }} | |
# SERVICE_NAME: ${{ matrix.service.name }} | |
# SERVICE_DIR: ${{ matrix.service.dir }} | |
# SOLUTION_FILE: ${{ matrix.service.solution }} | |
# HELM_CHART: ${{ matrix.service.helmChart }} | |
# HELM_CHART_DIR: ${{ matrix.service.helmChartDir }} | |
gitVersion_SemVer: ${{ needs.discovery.outputs.gitVersion_SemVer }} | |
gitVersion_AssemblySemFileVer: ${{ needs.discovery.outputs.gitVersion_AssemblySemFileVer }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: artifacts - prepare directories | |
run: | | |
mkdir -p .artifacts/helm | |
mkdir -p .artifacts/kubectl | |
- name: helm - import README | |
run: cp README.md src/helm/reflector/README.md | |
- name: helm - package chart | |
run: helm package --destination .artifacts/helm --version ${{ env.gitVersion_SemVer }} --app-version ${{ env.gitVersion_SemVer }} src/helm/reflector | |
- name: helm - template chart | |
run: helm template --namespace kube-system reflector .artifacts/helm/reflector${{ env.gitVersion_SemVer }}.tgz > .artifacts/kubectl/reflector-${{ env.gitVersion_SemVer }}.yaml | |
- name: "artifacts - upload - helm chart" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: helm | |
path: .artifacts/helm | |
- name: "artifacts - upload - artifacthub" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacthub | |
path: src/helm/artifacthub-repo.yaml | |
- name: "artifacts - upload - kubectl manifests" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: kubectl | |
path: .artifacts/kubectl | |
- name: tools - docker - register QEMU | |
run: | | |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
- name: tools - docker - setup buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker-container # REQUIRED for multi-platform builds | |
- name: tools - docker - login docker.io | |
if: ${{ needs.discovery.outputs.requiresBuildPush == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.ES_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.ES_DOCKERHUB_PAT }} | |
- name: tools - docker - login ghcr.io | |
if: ${{ needs.discovery.outputs.requiresBuildPush == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GITHUB_ACTOR }} | |
password: ${{ secrets.ES_GITHUB_PAT }} | |
- name: docker - build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: src/ | |
file: src/ES.Kubernetes.Reflector/Dockerfile | |
push: ${{ needs.discovery.outputs.requiresBuildPush == 'true' }} | |
provenance: false | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
tags: | | |
${{ env.dockerHubContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }} | |
${{ env.ghcrContainerImageRepository }}/${{ env.containerImage }}:${{ env.gitVersion_SemVer }} |