Skip to content

Commit

Permalink
feat(helmfile-actions): Helmfile sync action (#286)
Browse files Browse the repository at this point in the history
* feat(helmfile-actions): Helmfile sync action

* adding more information on to the readme
  • Loading branch information
lapierrejl authored Jun 15, 2022
1 parent 5862682 commit 53a7525
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions helmfile-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Example usage of `helmfile diff`:
command: diff
working_directory: helmfile/
```
Helmfile apply first does a diff between the last deployment and the locally rendered helmfile and deploys only the delta between the two. Helmfile apply only increments the release version if a delta is found. This may not detect manual changes made to helm releases if there is no delta between the last deployment and the current helmfile.

Example usage of `helmfile apply`:

Expand All @@ -37,3 +38,13 @@ Example usage of `helmfile apply`:
command: apply
working_directory: helmfile/
```
Helmfile sync always updates all releases and applies everything in the rendered helmfile. Sync takes longer to run but will detect and revert any manual changes made outside of the helmfile. Helmfile sync will always increment release version even if there is no change, keep this in mind if a helm rollback is required.

Example usage of `helmfile sync`:

```yaml
- uses: iStreamPlanet/github-actions/helmfile-actions@main
with:
command: sync
working_directory: helmfile/
```
4 changes: 4 additions & 0 deletions helmfile-actions/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function main {
scriptDir=$(dirname ${0})
source ${scriptDir}/diff.sh
source ${scriptDir}/apply.sh
source ${scriptDir}/sync.sh

case "${command}" in
diff)
Expand All @@ -19,6 +20,9 @@ function main {
apply)
helmfileApply
;;
sync)
helmfileSync
;;
*)
echo "Error: Unrecognized command ${command}"
exit 1
Expand Down
19 changes: 19 additions & 0 deletions helmfile-actions/sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

function helmfileSync {
set -o pipefail
tempfile=$(mktemp)
helmfile sync 2>&1 | tee $tempfile
exitCode=$?
output=$(cat $tempfile)
rm $tempfile

if [ ${exitCode} -eq 0 ]; then
echo "Successfully ran helmfile sync command."
else
echo "Error: Failed to run helmfile sync"
fi

echo
exit ${exitCode}
}

0 comments on commit 53a7525

Please sign in to comment.