Skip to content

Commit 236a49e

Browse files
fix: update cron job names and permissions in workflow files; add example .env file (#178)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 911be7f commit 236a49e

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
@@ -38,6 +38,8 @@ For example:
3838
<i>To be done</i>
3939

4040

41+
42+
4143
# Usage
4244
<i>To be done</i>
4345

@@ -56,3 +58,32 @@ For example:
5658
| python3 | Binary | For running more complex scripts during deployment process. | https://www.python.org/ |
5759
| requests | Python library | For sending HTTP requests, for example integration with Slack | https://github.com/psf/requests |
5860
| slack_sdk | Python library | For integration with Slack applications/bots, e.g. creating channels for notifications | https://github.com/slackapi/python-slack-sdk |
61+
62+
## Forking
63+
To publish images from a fork, set these variables so Task uses your registry identities:
64+
`DOCKER_USERNAME`, `DOCKER_ORG_NAME`, `GITHUB_USERNAME`, `GITHUB_ORG_NAME`.
65+
66+
Two supported options (environment variables take precedence over `.env`):
67+
```bash
68+
# .env (local only, not committed)
69+
DOCKER_USERNAME=your-dockerhub-user
70+
DOCKER_ORG_NAME=your-dockerhub-org
71+
GITHUB_USERNAME=your-github-user
72+
GITHUB_ORG_NAME=your-github-org
73+
```
74+
75+
```bash
76+
# Shell override
77+
DOCKER_USERNAME=your-dockerhub-user \
78+
DOCKER_ORG_NAME=your-dockerhub-org \
79+
GITHUB_USERNAME=your-github-user \
80+
GITHUB_ORG_NAME=your-github-org \
81+
task docker:build
82+
```
83+
84+
Recommended setup:
85+
- Local development: use a `.env` file.
86+
- GitHub Actions: set repo variables for the four values above, and secrets for `DOCKER_TOKEN` and `GITHUB_TOKEN`.
87+
88+
Publish images without a release:
89+
- 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
scripts: ./Taskfile.scripts.yml

0 commit comments

Comments
 (0)