Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: rename docker-cmd-file to docker-entrypoint-file #866

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
with:
configurationFile: ${{ matrix.configurationFile }}
renovate-version: ${{ env.RENOVATE_VERSION }}
docker-cmd-file: example/entrypoint.sh
docker-entrypoint-file: example/entrypoint.sh
docker-user: root

release:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GitHub Action to run Renovate self-hosted.
- [Badges](#badges)
- [Options](#options)
- [`configurationFile`](#configurationfile)
- [`docker-cmd-file`](#docker-cmd-file)
- [`docker-entrypoint-file`](#docker-entrypoint-file)
- [`docker-network`](#docker-network)
- [`docker-socket-host-path`](#docker-socket-host-path)
- [`docker-user`](#docker-user)
Expand Down Expand Up @@ -67,11 +67,10 @@ This disables the requirement of a configuration file for the repository and dis
requireConfig: false,
```

### `docker-cmd-file`
### `docker-entrypoint-file`

Specify a command to run when the image start.
By default the image run
`renovate`.
Specify an entrypoint file to run when the image starts.
The default is [renovate-entrypoint.sh](https://github.com/renovatebot/renovate/blob/main/tools/docker/bin/renovate-entrypoint.sh) located in `/usr/local/sbin/renovate-entrypoint.sh`
This option is useful to customize the image before running `renovate`.
It must be an existing executable file on the local system.
It will be mounted to the docker container.
Expand Down Expand Up @@ -102,7 +101,7 @@ jobs:
- name: Self-hosted Renovate
uses: renovatebot/[email protected]
with:
docker-cmd-file: .github/renovate-entrypoint.sh
docker-entrypoint-file: .github/renovate-entrypoint.sh
docker-user: root
token: ${{ secrets.RENOVATE_TOKEN }}
```
Expand All @@ -124,7 +123,7 @@ Only applicable when `mount-docker-socket` is true.

Specify a user (or user-id) to run docker command.

You can use it with [`docker-cmd-file`](#docker-cmd-file) in order to start the
You can use it with [`docker-entrypoint-file`](#docker-entrypoint-file) in order to start the
image as root, do some customization and switch back to a unprivileged user.

### `docker-volumes`
Expand Down Expand Up @@ -183,6 +182,7 @@ If you want to use the `github-actions` manager, you must setup a [special token
The Renovate Docker image name to use.
If omitted or `renovate-image === ''` the action will use the `ghcr.io/renovatebot/renovate` Docker image name otherwise.
If a Docker image name is defined, the action will use that name to pull the image.
Note: Use only the image name without a tag, [`renovate-version`](#renovate-version) is used as the image tag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated, please open a separate PR


This sample will use `myproxyhub.domain.com/renovate/renovate` image.

Expand Down
12 changes: 8 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ inputs:
env-regex:
description: |
Override the environment variables which will be passsed into the renovate container.
Defaults to `^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|(?:HTTPS?|NO)_PROXY|(?:https?|no)_proxy)$`
Defaults to `^(?:RENOVATE_\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|(?:HTTPS?|NO)_PROXY|(?:https?|no)_proxy)$`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change unrelated things

required: false
renovate-version:
description: |
Renovate version to use. Defaults to latest.
Renovate version to use. Also used as image tag together with the parameter `renovate-image`. Defaults to latest.
required: false
renovate-image:
description: |
Renovate docker image name.
Renovate docker image name. Use the parameter `renovate-version` to set the image tag.
Defaults to `ghcr.io/renovatebot/renovate`.
required: false
mount-docker-socket:
Expand All @@ -43,9 +43,13 @@ inputs:
Only applicable when 'mount-docker-socket' is true.
required: false
default: /var/run/docker.sock
docker-entrypoint-file:
description: |
Override docker docker entrypoint. Use with `docker-user: root`. See the example for usage.
required: false
docker-cmd-file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add docker-cmd-file as deprecated input for now but don't document in readme. So we're backward compatible

description: |
Override docker command. Default command is `renovate`
Deprecated, keeping it around for the backward compatibility. Use `docker-entrypoint-file` instead.
required: false
docker-network:
description: |
Expand Down
13 changes: 10 additions & 3 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ class Input {
return core.getInput('docker-socket-host-path') || '/var/run/docker.sock';
}

getDockerCmdFile(): string | null {
const cmdFile = core.getInput('docker-cmd-file');
return !!cmdFile && cmdFile !== '' ? path.resolve(cmdFile) : null;
getDockerEntrypointFile(): string | null {
const cmdFile = core.getInput('docker-entrypoint-file');
const entryPointFile =
!!cmdFile && cmdFile !== ''
? cmdFile
: core.getInput('docker-entrypoint-file');
Comment on lines +81 to +85
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a single variable


return !!entryPointFile && entryPointFile !== ''
? path.resolve(entryPointFile)
: null;
Comment on lines +87 to +89
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return !!entryPointFile && entryPointFile !== ''
? path.resolve(entryPointFile)
: null;
return entryPointFile
? path.resolve(entryPointFile)
: null;

simplify

}

getDockerUser(): string | null {
Expand Down
8 changes: 4 additions & 4 deletions src/renovate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class Renovate {
);
}

const dockerCmdFile = this.input.getDockerCmdFile();
const dockerEntryPointFile = this.input.getDockerEntrypointFile();
let dockerCmd: string | null = null;
if (dockerCmdFile !== null) {
const baseName = path.basename(dockerCmdFile);
if (dockerEntryPointFile !== null) {
const baseName = path.basename(dockerEntryPointFile);
const mountPath = `/${baseName}`;
dockerArguments.push(`--volume ${dockerCmdFile}:${mountPath}`);
dockerArguments.push(`--volume ${dockerEntryPointFile}:${mountPath}`);
dockerCmd = mountPath;
}

Expand Down