Merge branch 'master' into renovate/docker-renovate-renovate-19.x

This commit is contained in:
Jeroen de Bruijn 2020-05-11 21:55:44 +02:00 committed by GitHub
commit 70278158e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 18 deletions

View file

@ -52,6 +52,10 @@ jobs:
e2e: e2e:
needs: [cleanup] needs: [cleanup]
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
configurationFile: [example/renovate-config.js, example/renovate.json]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2.1.0 uses: actions/checkout@v2.1.0
@ -62,8 +66,9 @@ jobs:
- name: Renovate test - name: Renovate test
uses: ./ uses: ./
with: with:
configurationFile: example/renovate-config.js configurationFile: ${{ matrix.configurationFile }}
token: ${{ secrets.RENOVATE_TOKEN }} token: ${{ secrets.RENOVATE_TOKEN }}
build: build:
needs: [lint, commitlint, e2e] needs: [lint, commitlint, e2e]
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -8,13 +8,11 @@ GitHub Action to run Renovate self-hosted.
- [Badges](#badges) - [Badges](#badges)
- [Options](#options) - [Options](#options)
- [`configurationFile`](#option-configurationFile) - [`configurationFile`](#configurationfile)
- [`token`](#option-token) - [`token`](#token)
- [Example](#example) - [Example](#example)
- [License](#license) - [License](#license)
<a name="badges"></a>
## Badges ## Badges
| Badge | Description | Service | | Badge | Description | Service |
@ -25,15 +23,13 @@ GitHub Action to run Renovate self-hosted.
| <a href="https://github.com/renovatebot/github-action/actions"><img alt="GitHub workflow status" src="https://img.shields.io/github/workflow/status/renovatebot/github-action/Build?style=flat-square"></a> | Build | GitHub Actions | | <a href="https://github.com/renovatebot/github-action/actions"><img alt="GitHub workflow status" src="https://img.shields.io/github/workflow/status/renovatebot/github-action/Build?style=flat-square"></a> | Build | GitHub Actions |
| <a href="https://github.com/renovatebot/github-action/actions"><img alt="GitHub workflow status" src="https://img.shields.io/github/workflow/status/renovatebot/github-action/Example?style=flat-square"></a> | Example | GitHub Actions | | <a href="https://github.com/renovatebot/github-action/actions"><img alt="GitHub workflow status" src="https://img.shields.io/github/workflow/status/renovatebot/github-action/Example?style=flat-square"></a> | Example | GitHub Actions |
<a name="options"></a>
## Options ## Options
<a name="option-configurationFile"></a>
## `configurationFile` ## `configurationFile`
Configuration file to configure Renovate. The configurations that can be done in this file consists of two parts, as listed below. Refer to the links to the [Renovate Docs](https://docs.renovatebot.com/) for all options and see the [`example/config.js`](./example/config.js) for an example configuration. Configuration file to configure Renovate. The supported configurations files can be one of the configuration files listed in the Renovate Docs for [Configuration Options](https://docs.renovatebot.com/configuration-options/) or a JavaScript file that exports a configuration object. For both of these options, an example can be found in the [example](./example) directory.
The configurations that can be done in this file consists of two parts, as listed below. Refer to the links to the [Renovate Docs](https://docs.renovatebot.com/) for all options.
1. [Self-Hosted Configuration Options](https://docs.renovatebot.com/self-hosted-configuration/) 1. [Self-Hosted Configuration Options](https://docs.renovatebot.com/self-hosted-configuration/)
2. [Configuration Options](https://docs.renovatebot.com/configuration-options/) 2. [Configuration Options](https://docs.renovatebot.com/configuration-options/)
@ -47,16 +43,12 @@ If you want to use this with just the single configuration file, make sure to in
requireConfig: false, requireConfig: false,
``` ```
<a name="option-token"></a>
## `token` ## `token`
[Generate a personal access token](https://github.com/settings/tokens), with the `repo:public_repo` scope for only public repositories or the `repo` scope for public and private repositories, and add it to _Secrets_ (repository settings) as `RENOVATE_TOKEN`. You can also create a token without a specific scope, which gives read-only access to public repositories, for testing. This token is only used by Renovate, see the [token configuration](https://docs.renovatebot.com/self-hosted-configuration/#token), and gives it access to the repositories. The name of the secret can be anything as long as it matches the argument given to the `token` option. [Generate a personal access token](https://github.com/settings/tokens), with the `repo:public_repo` scope for only public repositories or the `repo` scope for public and private repositories, and add it to _Secrets_ (repository settings) as `RENOVATE_TOKEN`. You can also create a token without a specific scope, which gives read-only access to public repositories, for testing. This token is only used by Renovate, see the [token configuration](https://docs.renovatebot.com/self-hosted-configuration/#token), and gives it access to the repositories. The name of the secret can be anything as long as it matches the argument given to the `token` option.
Note that the [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token) secret can't be used for authenticating Renovate. Note that the [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token) secret can't be used for authenticating Renovate.
<a name="example"></a>
## Example ## Example
This example uses a personal access token and will run every 15 minutes. The personal access token is configured as a GitHub secret named `RENOVATE_TOKEN`. This example uses the [`example/config.js`](./example/config.js) file as configuration. This example uses a personal access token and will run every 15 minutes. The personal access token is configured as a GitHub secret named `RENOVATE_TOKEN`. This example uses the [`example/config.js`](./example/config.js) file as configuration.
@ -78,6 +70,6 @@ jobs:
- name: Self-hosted Renovate - name: Self-hosted Renovate
uses: renovatebot/github-action@v1.0.0 uses: renovatebot/github-action@v1.0.0
with: with:
configurationFile: example/config.js configurationFile: example/renovate-config.js
token: ${{ secrets.RENOVATE_TOKEN }} token: ${{ secrets.RENOVATE_TOKEN }}
``` ```

29
example/renovate.json Normal file
View file

@ -0,0 +1,29 @@
{
"branchPrefix": "test-renovate/",
"dryRun": true,
"gitAuthor": "Renovate Bot <bot@renovateapp.com>",
"logLevel": "debug",
"onboarding": false,
"platform": "github",
"includeForks": true,
"repositories": [
"renovatebot/github-action",
"renovate-tests/cocoapods1",
"renovate-tests/gomod1"
],
"packageRules": [
{
"description": "lockFileMaintenance",
"updateTypes": [
"pin",
"digest",
"patch",
"minor",
"major",
"lockFileMaintenance"
],
"masterIssueApproval": false,
"stabilityDays": 0
}
]
}

View file

@ -6,6 +6,7 @@ import path from 'path';
class Renovate { class Renovate {
private configFileEnv = 'RENOVATE_CONFIG_FILE'; private configFileEnv = 'RENOVATE_CONFIG_FILE';
private tokenEnv = 'RENOVATE_TOKEN'; private tokenEnv = 'RENOVATE_TOKEN';
private dockerGroupName = 'docker';
private configFileMountDir = '/github-action'; private configFileMountDir = '/github-action';
private configFile: string; private configFile: string;
@ -47,7 +48,8 @@ class Renovate {
* required permissions on the Docker socket. * required permissions on the Docker socket.
*/ */
private getDockerGroupId(): string { private getDockerGroupId(): string {
const groups = fs.readFileSync('/etc/group', { const groupFile = '/etc/group';
const groups = fs.readFileSync(groupFile, {
encoding: 'utf-8', encoding: 'utf-8',
}); });
@ -57,8 +59,15 @@ class Renovate {
* *
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/ * Source: https://www.thegeekdiary.com/etcgroup-file-explained/
*/ */
const [, group] = /^docker:x:([1-9][0-9]*):$/m.exec(groups); const re = new RegExp(`^${this.dockerGroupName}:x:([1-9][0-9]*):`, 'm');
return group; const match = re.exec(groups);
if (!match || match.length < 2) {
throw new Error(
`Could not find group '${this.dockerGroupName}' in ${groupFile}`
);
}
return match[1];
} }
private validateArguments(): void { private validateArguments(): void {