Skip to content

Commit

Permalink
skip: merge (8d4ffe3) [skip release]
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate-bot committed Oct 16, 2023
2 parents 0dbf03d + 8d4ffe3 commit cc6668c
Showing 6 changed files with 102 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -94,6 +94,16 @@ jobs:
configurationFile: ${{ matrix.configurationFile }}
renovate-version: ${{ env.RENOVATE_VERSION }}

- name: Renovate test with entrypoint
uses: ./
env:
LOG_LEVEL: debug
with:
configurationFile: ${{ matrix.configurationFile }}
renovate-version: ${{ env.RENOVATE_VERSION }}
docker-cmd-file: example/entrypoint.sh
docker-user: root

release:
needs: [lint, commitlint, e2e]
runs-on: ubuntu-latest
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ GitHub Action to run Renovate self-hosted.
- [Badges](#badges)
- [Options](#options)
- [`configurationFile`](#configurationfile)
- [`docker-cmd-file`](#docker-cmd-file)
- [`docker-user`](#docker-user)
- [`env-regex`](#env-regex)
- [`mount-docker-socket`](#mount-docker-socket)
- [`token`](#token)
@@ -65,6 +67,53 @@ This disables the requirement of a configuration file for the repository and dis
requireConfig: false,
```

### `docker-cmd-file`

Specify a command to run when the image start.
By default the image run
`renovate`.
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.

For example you can create a simple script like this one (let's call it
`renovate-entrypoint.sh`).

```sh
#!/bin/bash

apt update

apt install -y build-essential libpq-dev

runuser -u ubuntu renovate
```

Now use this action

```yml
....
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Self-hosted Renovate
uses: renovatebot/[email protected]
with:
docker-cmd-file: .github/renovate-entrypoint.sh
docker-user: root
token: ${{ secrets.RENOVATE_TOKEN }}
```
### `docker-user`

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
image as root, do some customization and switch back to a unprivileged user.

### `env-regex`

Allows to configure the regex to define which environment variables are passed to the renovate container.
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -36,6 +36,15 @@ inputs:
can use Docker. Also add the user inside the renovate container to the
docker group for socket permissions.
required: false
docker-cmd-file:
description: |
Override docker command. Default command is `renovate`
required: false
docker-user:
description: |
Docker user. Default to an unprivileged user
required: false

runs:
using: node16
main: dist/index.js
7 changes: 7 additions & 0 deletions example/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

set -e

install-apt sl

exec runuser -u ubuntu renovate
9 changes: 9 additions & 0 deletions src/input.ts
Original file line number Diff line number Diff line change
@@ -73,6 +73,15 @@ class Input {
return core.getInput('mount-docker-socket') === 'true';
}

getDockerCmdFile(): string | null {
const cmdFile = core.getInput('docker-cmd-file');
return !!cmdFile && cmdFile !== '' ? path.resolve(cmdFile) : null;
}

getDockerUser(): string | null {
return core.getInput('docker-user') || null;
}

/**
* Convert to environment variables.
*
18 changes: 18 additions & 0 deletions src/renovate.ts
Original file line number Diff line number Diff line change
@@ -39,8 +39,26 @@ class Renovate {
);
}

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

const dockerUser = this.input.getDockerUser();
if (dockerUser !== null) {
dockerArguments.push(`--user ${dockerUser}`);
}

dockerArguments.push('--volume /tmp:/tmp', '--rm', this.docker.image());

if (dockerCmd !== null) {
dockerArguments.push(dockerCmd);
}

const command = `docker run ${dockerArguments.join(' ')}`;

const code = await exec(command);

0 comments on commit cc6668c

Please sign in to comment.