Skip to content

Commit

Permalink
feat: add repo taskfile for cleaning up repo
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Buhl <[email protected]>
  • Loading branch information
onedr0p committed Jan 12, 2024
1 parent 00ec522 commit 1ff3c25
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"kustomize": {
"fileMatch": [
"(^|/)kustomization\\.ya?ml(\\.j2)?$"
"(^|/)kustomization\\.ya?ml(\\.j2)?(\\.j2)?$"
]
},
// commit message topics
Expand Down Expand Up @@ -228,7 +228,7 @@
"(^|/)addons/.+\\.ya?ml(\\.j2)?(\\.j2)?$",
"(^|/)ansible/.+\\.ya?ml(\\.j2)?(\\.j2)?$",
"(^|/)kubernetes/.+\\.ya?ml(\\.j2)?(\\.j2)?$",
"(^|/)k0s/.+\\.ya?ml(\\.j2)?(\\.j2)?$"
"(^|/)k0s-config.ya?ml(\\.j2)?(\\.j2)?$"
],
"matchStrings": [
// Example: `k3s_release_version: "v1.27.3+k3s1"`
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ kubeconfig
*.agekey
*.pub
*.key
# Private
.private
# Ansible
.venv*
# Taskfile
Expand Down
12 changes: 6 additions & 6 deletions .taskfiles/FluxTasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ tasks:
- { msg: "Flux already appears installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 1 || exit 0" }
- { msg: "Age private key not found", sh: "test -f {{.ROOT_DIR}}/age.key" }

github-deploy-key:
cmds:
- sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply -f -
preconditions:
- { msg: "Flux is not installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 0 || exit 1" }

apply:
desc: Apply a Flux Kustomization resource for a cluster
summary: |
Expand All @@ -61,3 +55,9 @@ tasks:
reconcile:
desc: Force update Flux to pull in changes from your Git repository
cmd: flux reconcile --namespace flux-system kustomization cluster --with-source

github-deploy-key:
cmds:
- sops --decrypt {{.KUBERNETES_DIR}}/bootstrap/github-deploy-key.sops.yaml | kubectl apply --server-side --filename -
preconditions:
- { msg: "Flux is not installed", sh: "kubectl get namespace flux-system &>/dev/null && exit 0 || exit 1" }
36 changes: 36 additions & 0 deletions .taskfiles/RepoTasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"

tasks:

clean:
desc: Clean files and directories no longer needed after cluster bootstrap
cmds:
# Move bootstrap directory to gitignored directory
- mkdir -p {{.ROOT}}/.private
- mv {{.ROOT}}/bootstrap {{.ROOT}}/.private
# Update renovate.json5
- sed -i '' 's/(..\.j2)\?(..\.j2)\?//g' {{.ROOT}}/.github/renovate.json5
- sed -i '' 's/addons/d' {{.ROOT}}/.github/renovate.json5
preconditions:
- { msg: "bootstrap dir not found", sh: "test -d {{.ROOT}}/bootstrap" }
- { msg: "renovate.json5 not found", sh: "test -f {{.ROOT_DIR}}/.github/renovate.json5" }

reset:
desc: Remove templated configuration files
prompt: Remove templated configuration files... continue?
cmds:
- rm -rf {{.ROOT}}/.sops.yaml
- rm -rf {{.ROOT}}/k0s-config.yaml
- rm -rf {{.ROOT}}/ansible
- rm -rf {{.ROOT}}/kubernetes

reset-repo:
desc: Set repo back to HEAD
prompt: Set repo back to HEAD... continue?
cmds:
- task: reset
- git reset --hard HEAD
- git clean -f -d
- git pull
1 change: 1 addition & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ includes:
taskfile: .taskfiles/KubernetesTasks.yaml
flux: .taskfiles/FluxTasks.yaml
k0s: .taskfiles/K0sTasks.yaml
repo: .taskfiles/RepoTasks.yaml

tasks:

Expand Down

0 comments on commit 1ff3c25

Please sign in to comment.