Skip to content

Commit 51a19ac

Browse files
fix: update cron job names and permissions in workflow files; add example .env file
1 parent 27149cb commit 51a19ac

File tree

7 files changed

+81
-39
lines changed

7 files changed

+81
-39
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DOCKER_USERNAME=your-dockerhub-user
2+
DOCKER_ORG_NAME=your-dockerhub-org
3+
DOCKER_TOKEN=your-docker-token
4+
GITHUB_USERNAME=your-github-user
5+
GITHUB_ORG_NAME=your-github-org
6+
GITHUB_TOKEN=your-github-token

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: (Cron) Weekly repository health
1+
name: (Cron) Check dependencies
22

33
on:
44
schedule:
55
- cron: 0 5 * * 1
66
workflow_dispatch:
77

88
permissions:
9-
contents: read
10-
issues: write
11-
pull-requests: read
9+
contents: write
10+
pull-requests: write
1211
packages: write
12+
issues: read
1313

1414
jobs:
1515
call:

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 4 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 "$@"' --
34+
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work hadolint/hadolint:latest-debian /bin/hadolint "$@"' --
3535
language: system
36-
files: '(^|/)Dockerfile(\..*)?$'
36+
files: (^|/)Dockerfile(\..*)?$
3737
- id: shellcheck
3838
name: shellcheck
3939
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work koalaman/shellcheck:stable -x -S style "$@"' --
4040
language: system
41-
files: '\.sh$'
41+
files: \.sh$
4242
- id: yamllint
4343
name: yamllint
4444
entry: bash -lc 'docker run --rm -v "$PWD:/work" -w /work cytopia/yamllint -c .yamllint.yml "$@"' --
4545
language: system
46-
files: '\.(yml|yaml)$'
46+
files: \.(yml|yaml)$

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ This action supports three tag levels for flexible versioning:
4343
- `vX.Y.Z`: fixed to a specific release (e.g., `v1.2.3`).
4444

4545

46+
47+
4648
## 📖 API Reference
4749

4850
```yaml
@@ -262,3 +264,32 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
262264
If you have any questions or need help, please:
263265
- 📝 Create an [issue](https://github.com/devops-infra/action-commit-push/issues)
264266
- 🌟 Star this repository if you find it useful!
267+
268+
## Forking
269+
To publish images from a fork, set these variables so Task uses your registry identities:
270+
`DOCKER_USERNAME`, `DOCKER_ORG_NAME`, `GITHUB_USERNAME`, `GITHUB_ORG_NAME`.
271+
272+
Two supported options (environment variables take precedence over `.env`):
273+
```bash
274+
# .env (local only, not committed)
275+
DOCKER_USERNAME=your-dockerhub-user
276+
DOCKER_ORG_NAME=your-dockerhub-org
277+
GITHUB_USERNAME=your-github-user
278+
GITHUB_ORG_NAME=your-github-org
279+
```
280+
281+
```bash
282+
# Shell override
283+
DOCKER_USERNAME=your-dockerhub-user \
284+
DOCKER_ORG_NAME=your-dockerhub-org \
285+
GITHUB_USERNAME=your-github-user \
286+
GITHUB_ORG_NAME=your-github-org \
287+
task docker:build
288+
```
289+
290+
Recommended setup:
291+
- Local development: use a `.env` file.
292+
- GitHub Actions: set repo variables for the four values above, and secrets for `DOCKER_TOKEN` and `GITHUB_TOKEN`.
293+
294+
Publish images without a release:
295+
- Run the `(Manual) Update Version` workflow with `build_only: true` to build and push images without tagging a release.

Taskfile.docker.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,39 @@ tasks:
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

Taskfile.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: '3'
22

33
silent: true
44

5+
dotenv:
6+
- .env
7+
58
includes:
69
variables: ./Taskfile.variables.yml
710
cicd:

0 commit comments

Comments
 (0)