-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathTaskfile.cicd.yml
More file actions
118 lines (98 loc) · 3.98 KB
/
Taskfile.cicd.yml
File metadata and controls
118 lines (98 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
version: '3'
silent: true
vars:
PR_TEMPLATE: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/PULL_REQUEST_TEMPLATE.md
CONFIGS_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/dockerized/configs
TASKFILES_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/dockerized/taskfiles
tasks:
pre-commit:
desc: Run all pre-commit hooks
cmds:
- pre-commit run --all-files
pre-commit:install:
desc: Install pre-commit hooks
cmds:
- pre-commit install
lint:
desc: Run all linters (Dockerfile, shell scripts, workflows, YAML)
cmds:
- task: lint:actionlint
- task: lint:hadolint
- task: lint:shellcheck
- task: lint:yamllint
lint:actionlint:
desc: Lint GitHub Actions workflows with actionlint
cmds:
- task: scripts:lint:actionlint
lint:hadolint:
desc: Lint Dockerfile with hadolint
cmds:
- task: scripts:lint:hadolint
lint:shellcheck:
desc: Lint shell scripts with shellcheck
cmds:
- task: scripts:lint:shellcheck
lint:yamllint:
desc: Lint YAML files with yamllint
cmds:
- task: scripts:lint:yamllint
version:get:
desc: Get current custom version (tf-*-ot-*-tg-*)
cmds:
- echo "{{.VERSION}}"
version:set:
desc: Set custom version in README and taskfile defaults
requires:
vars: [VERSION]
cmds:
- |
set -eu
version='{{.VERSION}}'
if ! printf "%s" "$version" | grep -Eq '^tf-[0-9]+\.[0-9]+\.[0-9]+-ot-[0-9]+\.[0-9]+\.[0-9]+-tg-[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "❌ ERROR: VERSION '$version' must match tf-X.Y.Z-ot-X.Y.Z-tg-X.Y.Z"
exit 1
fi
tf="$(printf "%s" "$version" | sed -E \
's/^tf-([0-9]+\.[0-9]+\.[0-9]+)-ot-([0-9]+\.[0-9]+\.[0-9]+)-tg-([0-9]+\.[0-9]+\.[0-9]+)$/\1/')"
ot="$(printf "%s" "$version" | sed -E \
's/^tf-([0-9]+\.[0-9]+\.[0-9]+)-ot-([0-9]+\.[0-9]+\.[0-9]+)-tg-([0-9]+\.[0-9]+\.[0-9]+)$/\2/')"
tg="$(printf "%s" "$version" | sed -E \
's/^tf-([0-9]+\.[0-9]+\.[0-9]+)-ot-([0-9]+\.[0-9]+\.[0-9]+)-tg-([0-9]+\.[0-9]+\.[0-9]+)$/\3/')"
echo "Updating TF_VERSION -> $tf"
echo "Updating OT_VERSION -> $ot"
echo "Updating TG_VERSION -> $tg"
{{.SED}} -i "s/\${TF_VERSION:-[0-9]\+\.[0-9]\+\.[0-9]\+}/\${TF_VERSION:-$tf}/g" Taskfile.terragrunt.yml
{{.SED}} -i "s/\${OT_VERSION:-[0-9]\+\.[0-9]\+\.[0-9]\+}/\${OT_VERSION:-$ot}/g" Taskfile.terragrunt.yml
{{.SED}} -i "s/\${TG_VERSION:-[0-9]\+\.[0-9]\+\.[0-9]\+}/\${TG_VERSION:-$tg}/g" Taskfile.terragrunt.yml
{{.SED}} -i "s/Terraform v[0-9]\+\.[0-9]\+\.[0-9]\+/Terraform v$tf/g" README.md
{{.SED}} -i "s/OpenTofu v[0-9]\+\.[0-9]\+\.[0-9]\+/OpenTofu v$ot/g" README.md
{{.SED}} -i "s/Terragrunt v[0-9]\+\.[0-9]\+\.[0-9]\+/Terragrunt v$tg/g" README.md
version:tag-release:
desc: Create custom release tag only
cmds:
- |
set -eu
version='{{.VERSION}}'
if ! printf "%s" "$version" | grep -Eq '^tf-[0-9]+\.[0-9]+\.[0-9]+-ot-[0-9]+\.[0-9]+\.[0-9]+-tg-[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "❌ ERROR: VERSION '$version' must match tf-X.Y.Z-ot-X.Y.Z-tg-X.Y.Z"
exit 1
fi
if git ls-remote --tags origin "refs/tags/${version}" | grep -q .; then
echo "❌ ERROR: Tag '${version}' already exists on remote"
exit 1
fi
if git rev-parse --quiet --verify "refs/tags/${version}" >/dev/null 2>&1; then
echo "ℹ️ INFO: Tag '${version}' exists locally, pushing"
else
echo "ℹ️ INFO: Creating tag '${version}'"
git tag --annotate "${version}" --message "${version}"
fi
git push origin "refs/tags/${version}"
git:get-pr-template:
desc: Get pull request template
cmds:
- task: scripts:git:get-pr-template
git:set-config:
desc: Set git user config
cmds:
- task: scripts:git:set-config