diff --git a/delivery-k8s/action.yaml b/delivery-k8s/action.yaml index 70ccd38..99a5811 100644 --- a/delivery-k8s/action.yaml +++ b/delivery-k8s/action.yaml @@ -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" @@ -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 @@ -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="" @@ -181,4 +186,4 @@ runs: export ${{inputs.dockerImageTagEnvName}}=${{inputs.dockerImageTagEnv}} fi - ./helmfile --file ${{ inputs.baseDeployDir }}/$ENVIRONMENT/${{ inputs.helmfileName }} sync $HELM_EXTRA_ARGS \ No newline at end of file + ./helmfile --file ${{ inputs.baseDeployDir }}/$ENVIRONMENT/${{ inputs.helmfileName }} sync $HELM_EXTRA_ARGS diff --git a/destroy-environment/action.yaml b/destroy-environment/action.yaml index 2fe030d..a9992e3 100644 --- a/destroy-environment/action.yaml +++ b/destroy-environment/action.yaml @@ -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 diff --git a/helm-push/action.yaml b/helm-push/action.yaml index 4fe99ec..32e7ee8 100644 --- a/helm-push/action.yaml +++ b/helm-push/action.yaml @@ -74,7 +74,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 @@ -82,7 +82,7 @@ runs: 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 }}" @@ -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 }} \ No newline at end of file + helm push $CHART_NAME-${{ inputs.helmChartPackageVersion }}.tgz ${{ inputs.chartMuseumRepoName }} --version=${{ inputs.helmChartPackageVersion }} diff --git a/setup-node/action.yaml b/setup-node/action.yaml new file mode 100644 index 0000000..4b366c4 --- /dev/null +++ b/setup-node/action.yaml @@ -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-