File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ permissions:
4343 contents : read
4444 issues : write
4545 pull-requests : read
46+ packages : write
4647
4748jobs :
4849 dependency-check :
Original file line number Diff line number Diff line change 11# Meta repository for [ devops-infra] ( https://github.com/devops-infra ) organization
22
3-
43# Badge swag
54[
65![ GitHub repo] ( https://img.shields.io/badge/GitHub-devops--infra%2F.github-blueviolet.svg?style=plastic&logo=github )
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ version: '3'
22
33silent : true
44
5+ dotenv :
6+ - .env
7+
58includes :
69 variables : ./Taskfile.variables.yml
710 cicd :
Original file line number Diff line number Diff line change 66 docker:login :
77 desc : Login to hub.docker.com and ghcr.io
88 cmds :
9- - echo "Logging into Docker Hub as {{.DOCKER_USERNAME}}"
10- - echo "${DOCKER_TOKEN}" | docker login -u "{{.DOCKER_USERNAME}}" --password-stdin
11- - echo "Logging into GHCR as {{.GITHUB_USERNAME}}"
12- - echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "{{.GITHUB_USERNAME}}" --password-stdin
9+ - |
10+ set -eu
11+ docker_username='{{.DOCKER_USERNAME}}'
12+ github_username='{{.GITHUB_USERNAME}}'
13+ has_dockerhub=false
14+ has_ghcr=false
15+
16+ if [ -n "$docker_username" ] && [ -n "${DOCKER_TOKEN:-}" ]; then
17+ has_dockerhub=true
18+ fi
19+
20+ if [ -n "$github_username" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
21+ has_ghcr=true
22+ fi
23+
24+ if [ "$has_dockerhub" = false ] && [ "$has_ghcr" = false ]; then
25+ echo "❌ No registry credentials provided. Set DOCKER_USERNAME/DOCKER_TOKEN or GITHUB_USERNAME/GITHUB_TOKEN."
26+ exit 1
27+ fi
28+
29+ if [ "$has_dockerhub" = true ]; then
30+ echo "Logging into Docker Hub as $docker_username"
31+ printf '%s' "${DOCKER_TOKEN}" | docker login -u "$docker_username" --password-stdin
32+ else
33+ echo "⚠️ Skipping Docker Hub login (missing DOCKER_USERNAME/DOCKER_TOKEN)"
34+ fi
35+
36+ if [ "$has_ghcr" = true ]; then
37+ echo "Logging into GHCR as $github_username"
38+ printf '%s' "${GITHUB_TOKEN}" | docker login ghcr.io -u "$github_username" --password-stdin
39+ else
40+ echo "⚠️ Skipping GHCR login (missing GITHUB_USERNAME/GITHUB_TOKEN)"
41+ fi
1342
1443 docker:cmds :
1544 desc : Show full docker build command
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ version: '3'
22
33silent : true
44
5+ dotenv :
6+ - .env
7+
58includes :
69 variables : ./Taskfile.variables.yml
710 cicd :
Original file line number Diff line number Diff line change 66 docker:login :
77 desc : Login to hub.docker.com and ghcr.io
88 cmds :
9- - echo "Logging into Docker Hub as {{.DOCKER_USERNAME}}"
10- - echo "${DOCKER_TOKEN}" | docker login -u "{{.DOCKER_USERNAME}}" --password-stdin
11- - echo "Logging into GHCR as {{.GITHUB_USERNAME}}"
12- - echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "{{.GITHUB_USERNAME}}" --password-stdin
9+ - |
10+ set -eu
11+ docker_username='{{.DOCKER_USERNAME}}'
12+ github_username='{{.GITHUB_USERNAME}}'
13+ has_dockerhub=false
14+ has_ghcr=false
15+
16+ if [ -n "$docker_username" ] && [ -n "${DOCKER_TOKEN:-}" ]; then
17+ has_dockerhub=true
18+ fi
19+
20+ if [ -n "$github_username" ] && [ -n "${GITHUB_TOKEN:-}" ]; then
21+ has_ghcr=true
22+ fi
23+
24+ if [ "$has_dockerhub" = false ] && [ "$has_ghcr" = false ]; then
25+ echo "❌ No registry credentials provided. Set DOCKER_USERNAME/DOCKER_TOKEN or GITHUB_USERNAME/GITHUB_TOKEN."
26+ exit 1
27+ fi
28+
29+ if [ "$has_dockerhub" = true ]; then
30+ echo "Logging into Docker Hub as $docker_username"
31+ printf '%s' "${DOCKER_TOKEN}" | docker login -u "$docker_username" --password-stdin
32+ else
33+ echo "⚠️ Skipping Docker Hub login (missing DOCKER_USERNAME/DOCKER_TOKEN)"
34+ fi
35+
36+ if [ "$has_ghcr" = true ]; then
37+ echo "Logging into GHCR as $github_username"
38+ printf '%s' "${GITHUB_TOKEN}" | docker login ghcr.io -u "$github_username" --password-stdin
39+ else
40+ echo "⚠️ Skipping GHCR login (missing GITHUB_USERNAME/GITHUB_TOKEN)"
41+ fi
1342
1443 docker:cmds :
1544 desc : Show full docker build command
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ version: '3'
22
33silent : true
44
5+ dotenv :
6+ - .env
7+
58includes :
69 variables : ./Taskfile.variables.yml
710 scripts : ./Taskfile.scripts.yml
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ version: '3'
22
33silent : true
44
5+ dotenv :
6+ - .env
7+
58includes :
69 variables : ./Taskfile.variables.yml
710 scripts : ./Taskfile.scripts.yml
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ version: '3'
22
33silent : true
44
5+ dotenv :
6+ - .env
7+
58includes :
69 variables : ./Taskfile.variables.yml
710 scripts : ./Taskfile.scripts.yml
You can’t perform that action at this time.
0 commit comments