Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 44 additions & 39 deletions delivery-k8s/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,79 @@ description: |-
Deploy your applications to kubernetes using helm
inputs:
helmRepoFilePath:
description: 'Path to the encrypted helm repos file'
description: "Path to the encrypted helm repos file"
required: false
default: 'helm.repositories.yaml'
default: "helm.repositories.yaml"
helmfileName:
description: 'Name of the helmfile config'
description: "Name of the helmfile config"
required: false
default: 'helmfile.yaml'
default: "helmfile.yaml"
baseDeployDir:
description: 'Directory where different deployment enviroment folders are placed'
description: "Directory where different deployment enviroment folders are placed"
required: false
default: 'deploy'
default: "deploy"
environment:
description: 'Environment where to deploy the application. Must match with a the folder name inside "baseDeployDir". Inside the folder path a helmfile inside have to be placed'
required: false
default: ''
default: ""
appPrefix:
description: 'Prefix of application namespace deployed in to the cluster'
description: "Prefix of application namespace deployed in to the cluster"
required: true
default: ''
default: ""
projectPrefix:
description: 'Prefix of project namespace deployed in to the cluster'
description: "Prefix of project namespace deployed in to the cluster"
required: true
default: ''
default: ""
gcpProjectId:
description: 'Project id where the kubernetes cluster is located'
description: "Project id where the kubernetes cluster is located"
required: true
default: ''
default: ""
gcpServiceAccountKey:
description: 'Gcp service account key to use for authentication agains gcp'
description: "Gcp service account key to use for authentication agains gcp"
required: true
default: ''
default: ""
gkeClusterName:
description: 'GKE k8s cluster name'
description: "GKE k8s cluster name"
required: true
default: ''
default: ""
gcpClusterZone:
description: 'Gcp zone where the cluster is located'
description: "Gcp zone where the cluster is located"
required: true
default: ''
default: ""
helmfileVersion:
description: 'Version of helmfile'
description: "Version of helmfile"
required: false
default: 'v0.132.0'
default: "v0.132.0"
dockerImageDigest:
description: 'Docker image digest to be placed in the helm chart values. Require replaceDockerImage attr set to true'
description: "Docker image digest to be placed in the helm chart values. Require replaceDockerImage attr set to true"
required: false
default: ''
default: ""
dockerImageDigestKeyPath:
description: 'Yaml path in dot notation to Docker image digest value that needs to be replaced'
description: "Yaml path in dot notation to Docker image digest value that needs to be replaced"
required: false
default: 'base.deployment.image.digest'
default: "base.deployment.image.digest"
dockerImageTag:
description: 'Docker image tag to be placed in the helm chart values. Require replaceDockerImage attr set to true'
description: "Docker image tag to be placed in the helm chart values. Require replaceDockerImage attr set to true"
required: false
default: ''
default: ""
dockerImageTagKeyPath:
description: 'Yaml path in dot notation to Docker image tag value that needs to be replaced'
description: "Yaml path in dot notation to Docker image tag value that needs to be replaced"
required: false
default: 'base.deployment.image.tag'
default: "base.deployment.image.tag"
dockerImageTagEnv:
description: 'Exported docker image tag as environment variable to be used in helmfile values instead of set'
description: "Exported docker image tag as environment variable to be used in helmfile values instead of set"
required: false
default: ''
default: ""
dockerImageTagEnvName:
description: 'Name of the environment variable to be used as tag'
description: "Name of the environment variable to be used as tag"
required: false
default: 'DOCKER_IMAGE_TAG'
default: "DOCKER_IMAGE_TAG"
outputs:
namespace: # id of the output
description: 'The kubernetes namespace where the application is deployed to'
description: "The kubernetes namespace where the application is deployed to"
value: "${{ steps.deploy.outputs.namespace }}"
branch_short: # id of the output
description: 'The name of the kubernetes branch (eg: ft-some-name)'
description: "The name of the kubernetes branch (eg: ft-some-name)"
value: "${{ steps.deploy.outputs.branch_short }}"
runs:
using: "composite"
Expand Down Expand Up @@ -113,7 +113,7 @@ runs:
HELM_LOCAL_PASS="$(jq -r ".repositories[$counter].password | select (.!=null)" "$REPO_FILE")"
HELM_LOCAL_URL="$(jq -r ".repositories[$counter].url | select (.!=null)" "$REPO_FILE")"
if [ -n "$HELM_LOCAL_USER" ] ; then
helm repo add $repo $HELM_LOCAL_URL --username $HELM_LOCAL_USER --password $HELM_LOCAL_PASS
helm repo add $repo $HELM_LOCAL_URL --username $HELM_LOCAL_USER --password $HELM_LOCAL_PASS --pass-credentials
else
helm repo add $repo $HELM_LOCAL_URL
fi
Expand All @@ -132,9 +132,14 @@ runs:
shell: bash
id: deploy
run: |-
BRANCH_LOWER="$(echo "$GITHUB_REF" | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')"
if [ "${{ inputs.deployFromPR }}" != ""]; then
BRANCH_LOWER="$(echo "$GITHUB_HEAD_REF" | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')"
BRANCH_TYPE=$BRANCH_LOWER
else
BRANCH_LOWER="$(echo "$GITHUB_REF" | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')"
BRANCH_TYPE=$(echo $BRANCH_LOWER | cut -d'/' -f 3)
fi

BRANCH_TYPE=$(echo $BRANCH_LOWER | cut -d'/' -f 3)
FEAT_FULL_NAME="$(printf "%s" "${BRANCH_LOWER##*/}" )"
FEAT_NAME="${FEAT_FULL_NAME:0:30}"
NAMESPACE=""
Expand Down Expand Up @@ -181,4 +186,4 @@ runs:
export ${{inputs.dockerImageTagEnvName}}=${{inputs.dockerImageTagEnv}}
fi

./helmfile --file ${{ inputs.baseDeployDir }}/$ENVIRONMENT/${{ inputs.helmfileName }} sync $HELM_EXTRA_ARGS
./helmfile --file ${{ inputs.baseDeployDir }}/$ENVIRONMENT/${{ inputs.helmfileName }} sync $HELM_EXTRA_ARGS
5 changes: 2 additions & 3 deletions destroy-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ runs:
export NAMESPACE+="-hot-"$FEAT_NAME
export BRANCH_SHORT="hot-"$FEAT_NAME
echo "Deleting namespace $NAMESPACE for hotfix branch $BRANCH_LOWER"
kubectl delete namespace $NAMESPACE
kubectl delete namespace $NAMESPACE
else
echo "Error branch type do not match"
exit 1;
echo "Branch doesn't matches, all fine!"
fi
6 changes: 3 additions & 3 deletions helm-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ runs:
HELM_LOCAL_PASS="$(jq -r ".repositories[$counter].password | select (.!=null)" "$REPO_FILE")"
HELM_LOCAL_URL="$(jq -r ".repositories[$counter].url | select (.!=null)" "$REPO_FILE")"
if [ -n "$HELM_LOCAL_USER" ] ; then
helm repo add $repo $HELM_LOCAL_URL --username $HELM_LOCAL_USER --password $HELM_LOCAL_PASS
helm repo add $repo $HELM_LOCAL_URL --username $HELM_LOCAL_USER --password $HELM_LOCAL_PASS --pass-credentials
else
helm repo add $repo $HELM_LOCAL_URL
fi
((counter=counter+1))
done
- name: Install helm-push helm plugin
shell: bash
run: helm plugin install https://github.com/chartmuseum/helm-push.git
run: helm plugin install https://github.com/chartmuseum/helm-push.git --version=v0.9.0
- name: Override docker image tag to be used
shell: bash
run: ./yq w -i ${{ inputs.helmChartPath }}/values.yaml ${{ inputs.dockerImageTagKeyPath}} "${{ inputs.dockerImageTag }}"
Expand All @@ -96,4 +96,4 @@ runs:
shell: bash
run: |-
CHART_NAME=$(./yq r ${{ inputs.helmChartPath }}/Chart.yaml 'name')
helm push $CHART_NAME-${{ inputs.helmChartPackageVersion }}.tgz ${{ inputs.chartMuseumRepoName }} --version=${{ inputs.helmChartPackageVersion }}
helm push $CHART_NAME-${{ inputs.helmChartPackageVersion }}.tgz ${{ inputs.chartMuseumRepoName }} --version=${{ inputs.helmChartPackageVersion }}
34 changes: 34 additions & 0 deletions setup-node/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Set up node environment
author: mrBillin
description: Set up a job with code, node and cache node_modules

inputs:
node-version:
description: 'Node version'
required: false
default: '14.x'

outputs:
dependencies-cache-hit:
description: 'is the node_modules cached'
value: "${{ steps.dependencies-cache.outputs.cache-hit }}"

runs:
using: "composite"
steps:
- name: Git Checkout
uses: actions/checkout@v3
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: Cache node_modules
uses: actions/cache@v3
id: dependencies-cache
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-