Skip to content

Commit 584f798

Browse files
authored
Merge pull request #24 from RobertoBochet/allow-single-job
Allow to execute as single job
2 parents 452b574 + 34f5658 commit 584f798

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,19 @@ private repos, they will be created as private repos on your gitea server.
3434

3535
All configuration is performed through environment variables. Flags are considered `true` on `true`, `TRUE` or `1`.
3636

37-
| Parameter | Required | Type | Default | Description |
38-
|-----------------------------|----------|--------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39-
| GITHUB_USERNAME | yes | string | - | The name of the GitHub user or organisation to mirror. |
40-
| GITEA_URL | yes | string | - | The url of your Gitea server. |
41-
| GITEA_TOKEN | yes | string | - | The token for your gitea user (Settings -> Applications -> Generate New Token). **Attention: if this is set, the token will be transmitted to your specified Gitea instance!** |
42-
| GITHUB_TOKEN | no* | string | - | GitHub token (PAT). Is mandatory in combination with `MIRROR_PRIVATE_REPOSITORIES`. |
43-
| MIRROR_PRIVATE_REPOSITORIES | no | bool | FALSE | If set to `true` your private GitHub Repositories will be mirrored to Gitea. Requires `GITHUB_TOKEN`. |
44-
| SKIP_FORKS | no | bool | FALSE | If set to `true` will disable the mirroring of forks from your GitHub User / Organisation. |
45-
| DELAY | no | int | 3600 | Number of seconds between program executions. Setting this will only affect how soon after a new repo was created a mirror may appar on Gitea, but has no affect on the ongoing replication. |
46-
| DRY_RUN | no | bool | FALSE | If set to `true` will perform no writing changes to your Gitea instance, but log the planned actions. |
47-
| INCLUDE | no | string | "*" | Name based repository filter (include): If any filter matches, the repository will be mirrored. It supports glob format, multiple filters can be separated with commas (`,`) |
48-
| EXCLUDE | no | string | "" | Name based repository filter (exclude). If any filter matches, the repository will not be mirrored. It supports glob format, multiple filters can be separated with commas (`,`). `EXCLUDE` filters are applied after `INCLUDE` ones. |
37+
| Parameter | Required | Type | Default | Description |
38+
|-----------------------------|----------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39+
| GITHUB_USERNAME | yes | string | - | The name of the GitHub user or organisation to mirror. |
40+
| GITEA_URL | yes | string | - | The url of your Gitea server. |
41+
| GITEA_TOKEN | yes | string | - | The token for your gitea user (Settings -> Applications -> Generate New Token). **Attention: if this is set, the token will be transmitted to your specified Gitea instance!** |
42+
| GITHUB_TOKEN | no* | string | - | GitHub token (PAT). Is mandatory in combination with `MIRROR_PRIVATE_REPOSITORIES`. |
43+
| MIRROR_PRIVATE_REPOSITORIES | no | bool | FALSE | If set to `true` your private GitHub Repositories will be mirrored to Gitea. Requires `GITHUB_TOKEN`. |
44+
| SKIP_FORKS | no | bool | FALSE | If set to `true` will disable the mirroring of forks from your GitHub User / Organisation. |
45+
| DELAY | no | int | 3600 | Number of seconds between program executions. Setting this will only affect how soon after a new repo was created a mirror may appar on Gitea, but has no affect on the ongoing replication. |
46+
| DRY_RUN | no | bool | FALSE | If set to `true` will perform no writing changes to your Gitea instance, but log the planned actions. |
47+
| INCLUDE | no | string | "*" | Name based repository filter (include): If any filter matches, the repository will be mirrored. It supports glob format, multiple filters can be separated with commas (`,`) |
48+
| EXCLUDE | no | string | "" | Name based repository filter (exclude). If any filter matches, the repository will not be mirrored. It supports glob format, multiple filters can be separated with commas (`,`). `EXCLUDE` filters are applied after `INCLUDE` ones.
49+
| SINGLE_RUN | no | bool | FALSE | If set to `TRUE` the task is only executed once. |
4950

5051
### Docker
5152

docker-entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ do
1010
echo "Starting to create mirrors..."
1111
node /app/dist/index.js
1212

13+
case $SINGLE_RUN in
14+
(TRUE | true | 1) break;;
15+
esac
16+
1317
echo "Waiting for ${DELAY} seconds..."
1418
sleep "${DELAY}"
1519
done

src/configuration.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function configuration() {
4444
delay: readInt("DELAY") ?? defaultDelay,
4545
include: (readEnv("INCLUDE") ?? defaultInclude).split(",").map(f => f.trim()),
4646
exclude: (readEnv("EXCLUDE") ?? defaultExclude).split(",").map(f => f.trim()),
47+
singleRun: readBoolean("SINGLE_RUN"),
4748
};
4849

4950
if (config.github.privateRepositories && config.github.token === undefined) {

0 commit comments

Comments
 (0)