feat(volume-mount): mount docker volumes as input (#797)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
r-binder 2023-12-05 18:03:15 +01:00 committed by GitHub
parent 6bd5cd83c4
commit fcce0a0ee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View file

@ -13,6 +13,7 @@ GitHub Action to run Renovate self-hosted.
- [`configurationFile`](#configurationfile) - [`configurationFile`](#configurationfile)
- [`docker-cmd-file`](#docker-cmd-file) - [`docker-cmd-file`](#docker-cmd-file)
- [`docker-user`](#docker-user) - [`docker-user`](#docker-user)
- [`docker-volumes`](#docker-volumes)
- [`env-regex`](#env-regex) - [`env-regex`](#env-regex)
- [`mount-docker-socket`](#mount-docker-socket) - [`mount-docker-socket`](#mount-docker-socket)
- [`token`](#token) - [`token`](#token)
@ -114,6 +115,31 @@ 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-cmd-file`](#docker-cmd-file) in order to start the
image as root, do some customization and switch back to a unprivileged user. image as root, do some customization and switch back to a unprivileged user.
### `docker-volumes`
Specify volume mounts. Defaults to `/tmp:/tmp`.
The volume mounts are separated through `;`.
This sample will mount `/tmp:/tmp`, `/home:/home` and `/foo:/bar`.
```yml
....
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.3
- name: Self-hosted Renovate
uses: renovatebot/github-action@v39.1.3
with:
token: ${{ secrets.RENOVATE_TOKEN }}
docker-volumes: |
/tmp:/tmp ;
/home:/home ;
/foo:/bar
```
### `env-regex` ### `env-regex`
Allows to configure the regex to define which environment variables are passed to the renovate container. Allows to configure the regex to define which environment variables are passed to the renovate container.

View file

@ -44,6 +44,11 @@ inputs:
description: | description: |
Docker user. Default to an unprivileged user Docker user. Default to an unprivileged user
required: false required: false
docker-volumes:
description: |
Docker volume mounts. Default to /tmp:/tmp
default: /tmp:/tmp
required: false
runs: runs:
using: node16 using: node16

View file

@ -82,6 +82,14 @@ class Input {
return core.getInput('docker-user') || null; return core.getInput('docker-user') || null;
} }
getDockerVolumeMounts(): string[] {
return core
.getInput('docker-volumes')
.split(';')
.map((v) => v.trim())
.filter((v) => !!v);
}
/** /**
* Convert to environment variables. * Convert to environment variables.
* *

View file

@ -53,7 +53,11 @@ class Renovate {
dockerArguments.push(`--user ${dockerUser}`); dockerArguments.push(`--user ${dockerUser}`);
} }
dockerArguments.push('--volume /tmp:/tmp', '--rm', this.docker.image()); for (const volumeMount of this.input.getDockerVolumeMounts()) {
dockerArguments.push(`--volume ${volumeMount}`);
}
dockerArguments.push('--rm', this.docker.image());
if (dockerCmd !== null) { if (dockerCmd !== null) {
dockerArguments.push(dockerCmd); dockerArguments.push(dockerCmd);