Skip to content

Commit b90cbfb

Browse files
Updated baseline sync files and reusable workflow callers
1 parent da5cba1 commit b90cbfb

10 files changed

+91
-63
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# EditorConfig helps developers define and maintain consistent coding styles
21
root = true
32

43
[*]

.github/workflows/auto-create-pull-request.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ jobs:
1717
uses: devops-infra/.github/.github/workflows/reusable-auto-create-pull-request.yml@v1
1818
with:
1919
profile: actions
20-
secrets:
21-
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
20+
secrets: inherit

.github/workflows/cron-check-dependencies.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ permissions:
99
contents: read
1010
issues: write
1111
pull-requests: read
12+
packages: write
1213

1314
jobs:
1415
call:
1516
uses: devops-infra/.github/.github/workflows/reusable-cron-check-dependencies.yml@v1
1617
with:
1718
profile: actions
18-
secrets:
19-
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
19+
secrets: inherit

.github/workflows/manual-sync-common-files.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ jobs:
2424
with:
2525
sync-type: ${{ inputs.type }}
2626
template-profile: actions
27+
secrets: inherit

.github/workflows/manual-update-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
permissions:
2727
contents: write
2828
packages: write
29+
pull-requests: write
2930

3031
jobs:
3132
call:
@@ -35,5 +36,4 @@ jobs:
3536
explicit-version: ${{ inputs.version }}
3637
build-and-push-only: ${{ inputs.build_only }}
3738
profile: actions
38-
secrets:
39-
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
39+
secrets: inherit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.iml
44

55
# Custom
6+
.DS_Store
67
.tmp/
78
.venv
89
.venv/

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ repos:
3131
pass_filenames: false
3232
- id: hadolint
3333
name: hadolint
34-
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work hadolint/hadolint:latest-debian hadolint Dockerfile'
34+
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work hadolint/hadolint:latest-debian "$@"' --
3535
language: system
36-
pass_filenames: false
36+
files: '(^|/)Dockerfile(\..*)?$'
3737
- id: shellcheck
3838
name: shellcheck
39-
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style entrypoint.sh'
39+
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style "$@"' --
4040
language: system
41-
pass_filenames: false
41+
files: '\.sh$'
4242
- id: yamllint
4343
name: yamllint
44-
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work cytopia/yamllint -c .yamllint.yml .'
44+
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work cytopia/yamllint -c .yamllint.yml "$@"' --
4545
language: system
46-
pass_filenames: false
46+
files: '\.(yml|yaml)$'

.yamllint.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ extends: default
22
rules:
33
empty-lines:
44
max: 2
5+
max-end: 1
56
document-end:
67
present: false
78
document-start:
@@ -11,14 +12,12 @@ rules:
1112
indent-sequences: true
1213
check-multi-line-strings: false
1314
line-length:
14-
max: 140
15+
max: 220
1516
allow-non-breakable-inline-mappings: true
1617
new-line-at-end-of-file: enable
1718
new-lines:
1819
type: unix
19-
quoted-strings:
20-
required: only-when-needed
21-
extra-allowed: ['true', 'false']
20+
quoted-strings: disable
2221
trailing-spaces: {}
2322
truthy:
2423
allowed-values: ['true', 'false', 'yes', 'no']

Taskfile.cicd.yml

Lines changed: 74 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ version: '3'
33
silent: true
44

55
vars:
6-
PR_TEMPLATE: https://raw.githubusercontent.com/devops-infra/.github/master/PULL_REQUEST_TEMPLATE.md
7-
TEMPLATE_REPO_BASE_URL: https://raw.githubusercontent.com/devops-infra/template-action/refs/heads/master
6+
PR_TEMPLATE: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/PULL_REQUEST_TEMPLATE.md
7+
CONFIGS_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/configs
8+
TASKFILES_BASE_URL: https://raw.githubusercontent.com/devops-infra/.github/refs/tags/v1/templates/actions/taskfiles
89

910
tasks:
1011
pre-commit:
@@ -98,9 +99,12 @@ tasks:
9899
desc: Update version in README.md and action.yml
99100
cmds:
100101
- |
101-
# check if VERSION if different than VERSION_FROM_ACTION_YML
102-
if [ "{{.VERSION}}" = "{{.VERSION_FROM_ACTION_YML}}" ]; then
103-
echo "❌ ERROR: VERSION is same as VERSION_FROM_ACTION_YML ({{.VERSION}})"
102+
if [ -z "{{.VERSION}}" ]; then
103+
echo "❌ ERROR: VERSION is empty"
104+
exit 1
105+
fi
106+
if ! echo "{{.VERSION}}" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+$'; then
107+
echo "❌ ERROR: VERSION '{{.VERSION}}' is not a valid semantic version (expected vX.Y.Z or X.Y.Z)"
104108
exit 1
105109
fi
106110
- echo Updating full version from {{.VERSION_FROM_ACTION_YML}} to {{.VERSION}}
@@ -129,6 +133,53 @@ tasks:
129133
cmds:
130134
- task version:set VERSION=v{{.NEXT_MAJOR}}.0.0
131135

136+
version:resolve-next:
137+
desc: Resolve next version from bump type and profile
138+
cmds:
139+
- |
140+
set -eu
141+
bump_type="${BUMP_TYPE:-patch}"
142+
input_version="${INPUT_VERSION:-}"
143+
144+
normalize_version() {
145+
candidate="${1#v}"
146+
if ! printf "%s" "${candidate}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
147+
return 1
148+
fi
149+
printf "v%s" "${candidate}"
150+
}
151+
152+
current="$(task version:get 2>/dev/null || true)"
153+
154+
case "$bump_type" in
155+
set)
156+
[ -n "$input_version" ] || { echo "Missing version for type=set"; exit 1; }
157+
next="$(normalize_version "$input_version")" || {
158+
echo "Invalid explicit version: $input_version. Expected vX.Y.Z or X.Y.Z"
159+
exit 1
160+
}
161+
;;
162+
patch|minor|major)
163+
[ -n "$current" ] || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
164+
current="$(normalize_version "$current")" || { echo "Current version not found or invalid. Expected vX.Y.Z"; exit 1; }
165+
no_v="${current#v}"
166+
major="$(printf "%s" "$no_v" | awk -F. '{print $1}')"
167+
minor="$(printf "%s" "$no_v" | awk -F. '{print $2}')"
168+
patch="$(printf "%s" "$no_v" | awk -F. '{print $3}')"
169+
case "$bump_type" in
170+
patch) next="v${major}.${minor}.$((patch + 1))" ;;
171+
minor) next="v${major}.$((minor + 1)).0" ;;
172+
major) next="v$((major + 1)).0.0" ;;
173+
esac
174+
;;
175+
*)
176+
echo "Unknown type: $bump_type"
177+
exit 1
178+
;;
179+
esac
180+
181+
printf "%s" "$next"
182+
132183
version:tag-release:
133184
desc: Create set of git tags
134185
cmds:
@@ -214,65 +265,43 @@ tasks:
214265
- git config user.email "github-actions[bot]@users.noreply.github.com"
215266

216267
sync:all:
217-
desc: Sync all files with template-action
268+
desc: Sync all common files
218269
cmds:
219270
- task sync:configs
220271
- task sync:ignores
221272
- task sync:taskfiles
222-
- task sync:workflows
223273

224274
sync:configs:
225-
desc: Sync configuration files with template-action
275+
desc: Sync configuration files with devops-infra/.github
226276
cmds:
227277
- |
228-
echo "▶️ Syncing configuration files from template-action..."
229-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.editorconfig -o ./.editorconfig
230-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.hadolint.yaml -o ./.hadolint.yaml
231-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.pre-commit-config.yaml -o ./.pre-commit-config.yaml
232-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.shellcheckrc -o ./.shellcheckrc
233-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.yamllint.yml -o ./.yamllint.yml
278+
echo "▶️ Syncing configuration files from devops-infra/.github..."
279+
curl -fsSL {{.CONFIGS_BASE_URL}}/.editorconfig -o ./.editorconfig
280+
curl -fsSL {{.CONFIGS_BASE_URL}}/.hadolint.yaml -o ./.hadolint.yaml
281+
curl -fsSL {{.CONFIGS_BASE_URL}}/.pre-commit-config.yaml -o ./.pre-commit-config.yaml
282+
curl -fsSL {{.CONFIGS_BASE_URL}}/.shellcheckrc -o ./.shellcheckrc
283+
curl -fsSL {{.CONFIGS_BASE_URL}}/.yamllint.yml -o ./.yamllint.yml
234284
git add .editorconfig .hadolint.yaml .pre-commit-config.yaml .shellcheckrc .yamllint.yml
235285
echo "✅ Synced configuration files"
236286
237287
sync:ignores:
238-
desc: Sync ignore files with template-action
288+
desc: Sync ignore files with devops-infra/.github
239289
cmds:
240290
- |
241-
echo "▶️ Syncing ignore files from template-action..."
242-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.gitignore -o ./.gitignore
243-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.dockerignore -o ./.dockerignore
291+
echo "▶️ Syncing ignore files from devops-infra/.github..."
292+
curl -fsSL {{.CONFIGS_BASE_URL}}/.gitignore -o ./.gitignore
293+
curl -fsSL {{.CONFIGS_BASE_URL}}/.dockerignore -o ./.dockerignore
244294
git add .gitignore .dockerignore
245295
echo "✅ Synced ignore files"
246296
247297
sync:taskfiles:
248-
desc: Sync Taskfiles with template-action
298+
desc: Sync Taskfiles with devops-infra/.github
249299
cmds:
250300
- |
251-
echo "▶️ Syncing Taskfiles from template-action..."
252-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/Taskfile.yml -o ./Taskfile.yml
253-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/Taskfile.cicd.yml -o ./Taskfile.cicd.yml
254-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/Taskfile.docker.yml -o ./Taskfile.docker.yml
255-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/Taskfile.variables.yml -o ./Taskfile.variables.yml
301+
echo "▶️ Syncing Taskfiles from devops-infra/.github..."
302+
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.yml -o ./Taskfile.yml
303+
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.cicd.yml -o ./Taskfile.cicd.yml
304+
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.docker.yml -o ./Taskfile.docker.yml
305+
curl -fsSL {{.TASKFILES_BASE_URL}}/Taskfile.variables.yml -o ./Taskfile.variables.yml
256306
git add Taskfile*.yml
257307
echo "✅ Synced Taskfiles"
258-
259-
sync:workflows:
260-
desc: Sync GitHub workflows with template-action
261-
cmds:
262-
- |
263-
echo "▶️ Syncing GitHub workflows from template-action..."
264-
mkdir -p .github/workflows
265-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/auto-create-pull-request.yml \
266-
-o ./.github/workflows/auto-create-pull-request.yml
267-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/auto-create-release.yml \
268-
-o ./.github/workflows/auto-create-release.yml
269-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/cron-check-dependencies.yml \
270-
-o ./.github/workflows/cron-check-dependencies.yml
271-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/manual-sync-common-files.yml \
272-
-o ./.github/workflows/manual-sync-common-files.yml
273-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/workflows/manual-update-version.yml \
274-
-o ./.github/workflows/manual-update-version.yml
275-
curl -sL {{.TEMPLATE_REPO_BASE_URL}}/.github/dependabot.yml \
276-
-o ./.github/dependabot.yml
277-
git add .github/workflows/
278-
echo "✅ Synced GitHub workflows"

Taskfile.variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ vars:
4343
GHRC_NAME: ghcr.io/{{.GITHUB_ORG_NAME}}/{{.GITHUB_REPO}}
4444
DEFAULT_BRANCH: master
4545
VERSION_FROM_ACTION_YML:
46-
sh: 'grep "image: docker://{{.DOCKER_NAME}}:" action.yml | cut -d ":" -f 4'
46+
sh: 'grep "image: docker://{{.DOCKER_NAME}}:" action.yml 2>/dev/null | cut -d ":" -f 4'
4747
AUTHOR_FROM_ACTION_YML:
4848
sh: |
4949
grep -e "^author:" action.yml | head -1 | awk -F": " '{print $2}'

0 commit comments

Comments
 (0)