Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm pipeline #5

Merged
merged 103 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
d9f99e0
test
Mar 6, 2024
c5929db
test
Mar 6, 2024
6f21bd8
test
Mar 6, 2024
d487d08
test
Mar 6, 2024
d8b03bd
test
Mar 6, 2024
5913072
test
Mar 6, 2024
512cea2
test
Mar 6, 2024
26fef1d
test
Mar 6, 2024
7369088
test
Mar 6, 2024
80b877b
test
Mar 6, 2024
24b59cd
test
Mar 6, 2024
975f830
test
Mar 6, 2024
0e8a02e
test
Mar 6, 2024
27852c1
test
Mar 6, 2024
11c5142
test
Mar 6, 2024
a7d0afb
test
Mar 6, 2024
83ae4b7
test
Mar 7, 2024
9d44030
test
Mar 7, 2024
ca8a989
test
Mar 7, 2024
f521789
test
Mar 7, 2024
19f9e3a
test
Mar 7, 2024
cc5565d
added .idea files
Mar 7, 2024
979167e
added .idea files
Mar 7, 2024
7a0fba0
added .idea files
Mar 7, 2024
15b859f
added .idea files
Mar 7, 2024
dcffa43
test
Mar 7, 2024
b29d8bf
test
Mar 7, 2024
b755a64
test
Mar 7, 2024
c8cf9f4
test
Mar 7, 2024
b85286c
test
Mar 7, 2024
26eecb8
test
Mar 7, 2024
9e4f1e1
test
Mar 7, 2024
bf6f758
test
Mar 7, 2024
059106d
test
Mar 7, 2024
6fa4a27
test
Mar 7, 2024
919b675
test
Mar 7, 2024
6ac5128
test
Mar 7, 2024
974d3bb
test
Mar 7, 2024
fcb3e41
test
Mar 7, 2024
d950597
test
Mar 7, 2024
a52723a
test
Mar 7, 2024
d269945
test
Mar 7, 2024
7dd2817
test
Mar 7, 2024
ae804b5
test
Mar 7, 2024
3b189e9
test
Mar 7, 2024
454cf84
test
Mar 7, 2024
7c0f993
test
Mar 7, 2024
cb1678a
test
Mar 7, 2024
564e990
test
Mar 7, 2024
a3d9582
test
Mar 7, 2024
bdab582
test
Mar 7, 2024
2b5f85d
test
Mar 7, 2024
6336892
test
Mar 7, 2024
963d876
test
Mar 7, 2024
4061d45
test
Mar 7, 2024
6277fa7
test
Mar 7, 2024
2ba1b67
test
Mar 7, 2024
ca43139
test
Mar 7, 2024
e9d28f1
test
Mar 7, 2024
1abed69
test
Mar 7, 2024
5890bcc
test
Mar 7, 2024
bc0bb79
test
Mar 14, 2024
69be83d
test
Mar 14, 2024
5309c03
test
Mar 14, 2024
60b75ea
test
Mar 14, 2024
b48b538
test
Mar 14, 2024
95e4db4
test
Mar 14, 2024
3f6db7c
test
Mar 14, 2024
bf08851
test
Mar 14, 2024
73a48f4
test
Mar 14, 2024
bc98f25
test
Mar 14, 2024
47672f2
test
Mar 14, 2024
5c53042
test
Mar 14, 2024
e21f0c0
test
Mar 14, 2024
60350d9
test
Mar 14, 2024
0d094dc
test
Mar 14, 2024
fbcdeba
test
Mar 14, 2024
1acc828
test
Mar 14, 2024
1318e42
test
Mar 14, 2024
d990ca4
test
Mar 14, 2024
77afac3
test
Mar 14, 2024
eb254e0
test
Mar 14, 2024
9ea619b
test
Mar 14, 2024
1447693
test
Mar 14, 2024
e907d66
test
Mar 14, 2024
a784e10
test
Mar 14, 2024
483ba34
test
Mar 14, 2024
17522f6
test
Mar 14, 2024
a53c401
test
Mar 14, 2024
fe006ad
test
Mar 14, 2024
7bd0519
test
Mar 14, 2024
84cdea6
test
Mar 14, 2024
154cbc1
test
Mar 14, 2024
2a64a74
test
Mar 14, 2024
682498c
test
Mar 14, 2024
2e9bdaa
test
Mar 14, 2024
61fec15
test
Mar 14, 2024
b335d1d
test
Mar 14, 2024
580ef02
test
Mar 14, 2024
65c8ef4
fixed dollar
Mar 14, 2024
8578780
test
Mar 14, 2024
87adb9d
test
Mar 15, 2024
cbc89d7
updated naming
Mar 18, 2024
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
163 changes: 163 additions & 0 deletions .github/workflows/deploy-helm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Workflow to deploy helm chart do kubernetes.
on:
workflow_call:
inputs:
chart:
description: 'Name of helm chart'
required: true
type: string
chartpath:
description: 'Path to chart in registry'
default: 'helm-charts/'
required: false
type: string
command:
description: 'Helm command'
required: true
type: string
instance:
description: 'Type of helm deploy instance'
required: true
type: string
valuesfile:
description: 'File of helm chart values'
required: true
type: string
registry:
description: 'Registry where are helm charts stored'
default: 'harbor.bratislava.sk'
required: false
type: string
cluster:
description: 'Kubernetes cluster name'
default: 'tkg-innov-dev'
required: true
type: string
namespace:
description: 'Namespace where should be build app deployed'
default: 'standalone'
required: true
type: string
url:
description: 'Kubernetes cluster url'
default: 'https://tkg.dev.bratislava.sk'
required: true
type: string
username:
description: 'Helm registry username'
default: robot\$github_actions
required: false
type: string
secrets:
registry-pass:
description: 'Password for registry where docker is uploading images'
required: true
service-account:
# kubectl get secret default-token-7kvjs -n=standalone -o jsonpath='{.data.token}' | base64 --decode > token.tmp
description: 'Kubernetes service account'
required: true

jobs:
deploy:
name: Deploy helm
runs-on: ubuntu-latest
steps:
- name: Checking out
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@bratislava.sk"

- name: Pipelines Version
run: |
echo "Pipelines version: 2.1.0"

- name: Directory check
run: pwd

- name: Kubectl tool installer
uses: Azure/setup-kubectl@v4.0.0

- name: Kubernetes set service account token
# to obtain token run: kubectl get secret <service account secret> -n=standalone -o jsonpath='{.data.token}' | base64 --decode > token.tmp
run: kubectl config set-credentials default --token=${{ secrets.service-account }}

- name: Kubernetes set server with certificate account token
run: kubectl config set-cluster ${{ inputs.cluster }} --insecure-skip-tls-verify --server=${{ inputs.url }}

- name: Kubernetes set context cluster
run: kubectl config set-context ${{ inputs.cluster }} --cluster=${{ inputs.cluster }} --user=default

- name: Kubernetes use context
run: kubectl config use-context ${{ inputs.cluster }}

- name: Helm tool installer
uses: azure/setup-helm@v4.1.0

- name: Helm version
run: helm version

- name: Login to Harbor
run: |
echo "${{ secrets.registry-pass }}" | helm registry login -u "${{ inputs.username }}" --password-stdin "${{ inputs.registry }}"

- id: chartpath
name: Chart path
run: |
echo "CHPATH=oci://${{ inputs.registry }}/${{ inputs.chartpath }}${{ inputs.chart }}" >> $GITHUB_ENV

- id: chartinfo
name: Chart info
run: |
list=$(helm show chart ${CHPATH} | sed -En '/^(appVersion|description|name|version)/p' | sort | sed 's/^.*: //')
echo $list
readarray -t info <<< $list
echo "APPVERSION=${info[0]}" >> $GITHUB_ENV
echo "CHDESC=${info[1]}" >> $GITHUB_ENV
echo "CHNAME=${info[2]}" >> $GITHUB_ENV
echo "CHVERSION=${info[3]}" >> $GITHUB_ENV

- name: Print pipeline summary
run: |
echo "### Helm ${{ inputs.command }}:" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Chart: **${{ inputs.chart }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Description: **${CHDESC}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Chart Version: **${CHVERSION}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: App Version: **${APPVERSION}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Instance: **${{ inputs.instance }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Values File: **${{ inputs.valuesfile }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Cluster: **${{ inputs.cluster }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Namespace: **${{ inputs.namespace }}**" >> $GITHUB_STEP_SUMMARY

- name: Helm command to kubernetes
run: |
helm ${{ inputs.command }} ${{ inputs.instance }} -n ${{ inputs.namespace }} ${CHPATH} -f ${{ inputs.valuesfile }} --debug

- name: Print pipeline summary
run: |
echo "### Pipeline summary :ship:" >> $GITHUB_STEP_SUMMARY
echo ":partying_face: Helm successfully ${{ inputs.command }}ed **${{ inputs.instance }}** to ${{ inputs.cluster }}" >> $GITHUB_STEP_SUMMARY

- name: Print pipeline comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
${{ env.GITHUB_STEP_SUMMARY }}

- name: Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ inputs.instance }} ${{ inputs.command }} to ${{inputs.cluster}} with app version ${{ env.APPVERSION }} and chart ${{ env.CHVERSION }}
body: |
${{ env.GITHUB_STEP_SUMMARY }}
generate_release_notes: false
draft: false
prerelease: false
9 changes: 1 addition & 8 deletions .github/workflows/deploy-with-bratiska-cli-inhouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,4 @@ jobs:
- name: Print pipeline summary
run: |
echo "### Deployment summary :ship:" >> $GITHUB_STEP_SUMMARY
echo ":partying_face: Bratiska-cli successfully deployed to ${{ inputs.cluster }}" >> $GITHUB_STEP_SUMMARY

- name: Print pipeline comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
{{ env.GITHUB_STEP_SUMMARY }}
echo ":partying_face: Bratiska-cli successfully deployed to ${{ inputs.cluster }}" >> $GITHUB_STEP_SUMMARY
9 changes: 1 addition & 8 deletions .github/workflows/deploy-with-bratiska-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,4 @@ jobs:
- name: Print pipeline summary
run: |
echo "### Deployment summary :ship:" >> $GITHUB_STEP_SUMMARY
echo ":partying_face: Bratiska-cli successfully deployed to ${{ inputs.cluster }}" >> $GITHUB_STEP_SUMMARY

- name: Print pipeline comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
{{ env.GITHUB_STEP_SUMMARY }}
echo ":partying_face: Bratiska-cli successfully deployed to ${{ inputs.cluster }}" >> $GITHUB_STEP_SUMMARY
119 changes: 119 additions & 0 deletions .github/workflows/detect-helm-instance-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Workflow which detects what helm instance should be deployed
on:
workflow_call:
outputs:
command:
description: "Helm command value"
value: ${{ jobs.detect.outputs.command }}
cluster:
description: "cluster type as dev, staging or prod"
value: ${{ jobs.detect.outputs.cluster }}
instance:
description: "Returns value of instance"
value: ${{ jobs.detect.outputs.instance }}
valuesfile:
description: "Returns path of valuesfile"
value: ${{ jobs.detect.outputs.valuesfile }}

jobs:
detect:
name: Checking deployment conditions
runs-on: ubuntu-latest
outputs:
command: ${{ steps.out.outputs.command }}
cluster: ${{ steps.out.outputs.cluster }}
instance: ${{ steps.out.outputs.instance }}
valuesfile: ${{ steps.out.outputs.valuesfile }}
steps:
- name: Checking out
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Pipelines Version
run: |
echo "Pipelines version: 2.1.0"

- id: clean
name: Clean tag name
env:
REF_NAME: ${{ github.ref_name }}
run: |
echo "TAG=${REF_NAME##*/}" >> $GITHUB_ENV

- id: instance
name: Get instance
run: |
echo "INSTANCE=${TAG##*-}" >> $GITHUB_ENV

- id: cluster
name: Get cluster
run: |
echo "CLUSTER=${TAG%%-*}" >> $GITHUB_ENV

- id: subpart
name: Create subpart
run: |
echo "SUB=${TAG#*${CLUSTER}-}" >> $GITHUB_ENV

- id: command
name: Get command
run: |
echo "COMMAND=${SUB%%-*}" >> $GITHUB_ENV

- id: out
name: Set ouptuts
run: |
echo "command=${COMMAND}" >> $GITHUB_OUTPUT
echo "cluster=${CLUSTER}" >> $GITHUB_OUTPUT
echo "instance=${INSTANCE}" >> $GITHUB_OUTPUT
echo "valuesfile=deployments/${CLUSTER}/${INSTANCE}.yml" >> $GITHUB_OUTPUT

- name: Print Outputs
run: |
echo ${{ steps.out.outputs.command }}
echo ${{ steps.out.outputs.cluster }}
echo ${{ steps.out.outputs.instance }}
echo ${{ steps.out.outputs.valuesfile }}

- id: no-instance
if: env.INSTANCE == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no helm instances. Exiting pipeline with Fail status.')

- id: no-cluster
if: env.CLUSTER == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no cluster. Exiting pipeline with Fail status.')

- id: no-command
if: env.COMMAND == ''
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: We have no helm command. Exiting pipeline with Fail status.')

- id: unsupported-command
if: env.COMMAND != 'install' && env.COMMAND != 'upgrade' && env.COMMAND != 'uninstall'
uses: actions/github-script@v3
with:
script: |
core.setFailed(':heavy_exclamation_mark: Unsupported helm command. Only `install`, `upgrade` and `uninstall` are supported. Exiting pipeline with Fail status.')

- id: check_files
name: Check file existence
uses: andstor/file-existence-action@v3
with:
files: ${{ steps.out.outputs.valuesfile }}
fail: true

- name: Print info
run: |
echo "## Detected helm deployment :rocket:" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Command: **${{ steps.out.outputs.command }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Instance: **${{ steps.out.outputs.instance }}**" >> $GITHUB_STEP_SUMMARY
echo ":arrow_right: Cluster: **${{ steps.out.outputs.cluster }}**" >> $GITHUB_STEP_SUMMARY
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/github-actions.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.