Compare commits

..
1 Commits
Author SHA1 Message Date
github-actions[bot] 3ac9d13fb2 chore(release): 19.230.0 2020-05-05 07:48:45 +00:00
28 changed files with 5906 additions and 11123 deletions

No files matched your search

+13 -24
View File
@@ -1,11 +1,22 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier', 'json'],
parserOptions: {
sourceType: 'module',
},
env: {
es2020: true,
node: true,
},
plugins: ['@typescript-eslint', 'json'],
rules: {
'prettier/prettier': 'error',
'sort-imports': 'error',
},
ignorePatterns: [
@@ -19,26 +30,4 @@ module.exports = {
'node_modules/',
'!.*',
],
overrides: [
{
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2019,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
rules: {},
},
{
files: ['*.json'],
extends: ['plugin:json/recommended', 'prettier'],
},
],
};
+24 -24
View File
@@ -1,24 +1,32 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>renovatebot/.github", ":pinDependencies"],
"extends": [
"config:base",
":rebaseStalePrs",
":pinDependencies",
":masterIssue"
],
"prCreation": "not-pending",
"lockFileMaintenance": {
"enabled": true,
"masterIssueApproval": true
},
"major": {
"stabilityDays": 3,
"masterIssueApproval": true
},
"packageRules": [
{
"description": "Automerge Renovate updates",
"packageNames": ["renovate/renovate"],
"updateTypes": ["major", "minor", "patch"],
"semanticCommitType": "fix"
"description": "Automerge devDependencies updates",
"depTypeList": ["devDependencies"],
"updateTypes": ["pin", "digest", "patch", "minor"],
"automerge": true
},
{
"description": "Update references in markdown files weekly",
"matchPaths": [".md"],
"extends": ["schedule:weekly"],
"automerge": true,
"stabilityDays": 0,
"separateMajorMinor": false,
"commitMessageTopic": "references to {{{depName}}}",
"semanticCommitType": "docs",
"semanticCommitScope": null,
"additionalBranchPrefix": "docs-"
"description": "Automerge renovate minor and patch updates",
"packageNames": ["renovate/renovate"],
"updateTypes": ["minor", "patch"],
"semanticCommitType": "fix",
"automerge": true
}
],
"regexManagers": [
@@ -28,14 +36,6 @@
"// renovate: datasource=(?<datasource>[a-z-]+?) depName=(?<depName>.+?)(?: versioning=(?<versioning>[a-z-]+?))?\\s+readonly\\s+tag\\s+=\\s+'(?<currentValue>.+?)';"
],
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}"
},
{
"fileMatch": ["^README\\.md$"],
"matchStrings": [
"uses: renovatebot/github-action@(?<currentValue>[^\\s]+)"
],
"depNameTemplate": "renovatebot/github-action",
"datasourceTemplate": "github-releases"
}
]
}
+47 -114
View File
@@ -2,138 +2,71 @@ name: Build
on:
push:
branches:
- master
- 'renovate/**'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
jobs:
commitlint:
cleanup:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
timeout-minutes: 5
steps:
- name: github-cleanup
uses: renovatebot/internal-tools@v0
continue-on-error: true
with:
command: github-cleanup
token: ${{ secrets.GITHUB_TOKEN }}
commitlint:
needs: [cleanup]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
uses: actions/checkout@v2.1.0
with:
fetch-depth: 0
- name: Lint commit messages
uses: wagoid/commitlint-github-action@296247dfa6a133767fe0d64d08fb66326047b680 # renovate: tag=v4.1.9
continue-on-error: true
lint:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
- name: Setup node
uses: actions/setup-node@04c56d2f954f1e4c69436aa54cfef261a018f458 # renovate: tag=v2.5.0
with:
node-version: '12.x'
cache: 'yarn'
- name: Install project
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint
e2e:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
strategy:
fail-fast: false
matrix:
configurationFile: [example/renovate-config.js, example/renovate.json]
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
- name: Install project
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Configure renovate token
run: |
if [[ "${RENOVATE_TOKEN}" != "" ]]; then
echo "RENOVATE_TOKEN=${RENOVATE_TOKEN}" >> $GITHUB_ENV
else
echo "RENOVATE_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
fi
uses: wagoid/commitlint-github-action@v1.6.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
lint:
needs: [cleanup]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
- name: Setup node
uses: actions/setup-node@v1.4.1
with:
node-version: '12.x'
- name: Install project
run: npm ci
- name: Lint
run: npm run lint
e2e:
needs: [cleanup]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
- name: Install project
run: npm ci
- name: Build
run: npm run build
- name: Renovate test
uses: ./
env:
LOG_LEVEL: debug
with:
configurationFile: ${{ matrix.configurationFile }}
configurationFile: example/renovate-config.js
token: ${{ secrets.RENOVATE_TOKEN }}
build:
needs: [lint, commitlint, e2e]
runs-on: ubuntu-latest
steps:
- run: echo 'dummy'
release:
needs: [build]
runs-on: ubuntu-latest
if: |
startsWith(github.event.commits[0].message,
'fix(deps): update renovate/renovate docker tag ')
&& github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # renovate: tag=v2.4.0
with:
fetch-depth: 0
ref: 'release'
- name: Fetch tags
run: git fetch --tags
- name: Setup Git user
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Merge main
run: |
git merge -m 'chore(release): merge main (${{ github.sha }})' ${{ github.sha }}
- name: Setup node
uses: actions/setup-node@04c56d2f954f1e4c69436aa54cfef261a018f458 # renovate: tag=v2.5.0
with:
node-version: '12.x'
- name: Install project
run: yarn install --frozen-lockfile --ignore-scripts
- name: Get version
id: release
run: yarn release:version
- name: Release
run: yarn release -- "${{ steps.release.outputs.version }}"
- name: Get changelog section
id: changelog
run: |
changelog="$(git show --unified=0 CHANGELOG.md \
| tail +12 \
| sed -e 's/^\+//' \
| sed -z 's/\n/%0A/g;s/\r/%0D/g')"
echo "::set-output name=changelog::${changelog}"
- name: Publish release
run: git push --follow-tags
- name: Publish GitHub release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # renovate: tag=v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.release.outputs.version }}
release_name: v${{ steps.release.outputs.version }}
body: |
*See the the [changelog](
https://github.com/${{ github.repository }}/blob/release/CHANGELOG.md
) for changes in all releases.*
${{ steps.changelog.outputs.changelog }}
- run: echo 'Dummy'
+65
View File
@@ -0,0 +1,65 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
if: |
startsWith(github.event.commits[0].message, 'fix(deps): update renovate/renovate docker tag ')
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
with:
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags
- name: Setup Git user
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v1.4.1
with:
node-version: '12.x'
- name: Install project
run: npm ci
- name: Release
run: |
SEMVER_REGEX="v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
if [[ ! "${{ github.event.commits[0].message }}" =~ ${SEMVER_REGEX} ]]; then
echo Not a semver like version - aborting: ${1}
exit 1
fi
NEXT_VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
MAJOR_VERSION="${BASH_REMATCH[1]}"
echo "::set-env name=NEXT_VERSION::${NEXT_VERSION}"
echo "::set-env name=MAJOR_VERSION::${MAJOR_VERSION}"
npm version ${NEXT_VERSION} -m "chore(release): ${NEXT_VERSION}"
git tag "v${MAJOR_VERSION}"
- name: Publish release
run: |
git push origin "v${NEXT_VERSION}"
git push -f origin "v${MAJOR_VERSION}"
# - name: Publish GitHub release
# uses: actions/create-release@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ env.NEXT_VERSION }}
# release_name: v${{ env.NEXT_VERSION }}
# body: |
# See the the [changelog](
# https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md
# ) for the changes included in this release.
prevent_failed_status:
name: Prevent failed status when skipped
runs-on: ubuntu-latest
steps:
- name: Prevent failed status when skipped
run: |
echo "Run this job to prevent the workflow status from showing as" \
"failed when all other jobs are skipped."
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn commitlint --edit $1
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
hooks: {
'pre-commit': 'lint-staged',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
},
};
+4 -2
View File
@@ -1,4 +1,6 @@
module.exports = {
'*.{ts,tsx,js,jsx,json}': ['yarn lint-es:file:fix'],
'*.{js,jsx,ts,tsx,md,yml,yaml,json}': ['yarn format:file'],
'*.{ts,tsx,js,jsx,json}': ['npm run lint-es:file:fix'],
'*.{vue,ts,css,less,scss,html,htm,md,markdown,yml,yaml}': [
'npm run format:file',
],
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true,
};
-4
View File
@@ -1,4 +0,0 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
+1 -2
View File
@@ -1,7 +1,6 @@
module.exports = {
scripts: {
prerelease:
'if [ "$(git branch --show-current)" != "release" ]; then exit 1; fi',
'if [ "$(git branch --show-current)" != "master" ]; then exit 1; fi',
},
commitAll: true,
};
+18 -5242
View File
File diff suppressed because it is too large. Load diff
+16 -86
View File
@@ -8,12 +8,12 @@ GitHub Action to run Renovate self-hosted.
- [Badges](#badges)
- [Options](#options)
- [`configurationFile`](#configurationfile)
- [`token`](#token)
- [`configurationFile`](#option-configurationFile)
- [`token`](#option-token)
- [Example](#example)
- [Troubleshooting](#troubleshooting)
- [Debug Logging](#debug-logging)
- [Special token requirements when using the `github-actions` manager](#special-token-requirements-when-using-the-github-actions-manager)
- [License](#license)
<a name="badges"></a>
## Badges
@@ -25,15 +25,15 @@ 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/Example?style=flat-square"></a> | Example | GitHub Actions |
<a name="options"></a>
## Options
Options can be passed using the inputs of this action or the corresponding environment variables. When both are passed, the input takes precedence over the environment variable. For the available environment variables see the Renovate [Self-Hosted Configuration](https://docs.renovatebot.com/self-hosted-configuration/) docs.
<a name="option-configurationFile"></a>
## `configurationFile`
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.
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.
1. [Self-Hosted Configuration Options](https://docs.renovatebot.com/self-hosted-configuration/)
2. [Configuration Options](https://docs.renovatebot.com/configuration-options/)
@@ -47,20 +47,20 @@ If you want to use this with just the single configuration file, make sure to in
requireConfig: false,
```
<a name="option-token"></a>
## `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.
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.
If you want to use the `github-actions` manager, you must setup a [special token](#special-token-requirements-when-using-the-github-actions-manager) with some requirements.
<a name="example"></a>
## 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/renovate-config.js`](./example/renovate-config.js) file as configuration.
You can also see a live example of this action in my [github-renovate](https://github.com/vidavidorra/github-renovate) repository, which also includes a more [advanced configuration](https://github.com/vidavidorra/github-renovate/blob/master/src/renovate-config.ts) for updating GitHub Action workflows.
**Remark** Update the action version to the most current, see [here](https://github.com/renovatebot/github-action/releases/latest) for latest release.
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.
You can also see a live example of this action in my [github-renovate](https://github.com/vidavidorra/github-renovate) repository, which also includes a more [advanced configuration](https://github.com/vidavidorra/github-renovate/blob/master/src/config.js) for updating GitHub Action workflows.
```yml
name: Renovate
@@ -76,78 +76,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Self-hosted Renovate
uses: renovatebot/github-action@v29.27.0
uses: renovatebot/github-action@v1.0.0
with:
configurationFile: example/renovate-config.js
configurationFile: example/config.js
token: ${{ secrets.RENOVATE_TOKEN }}
```
## Example with GitHub App
Instead of using a Personal Access Token (PAT) that is tied to a particular user you can use a [GitHub App](https://docs.github.com/en/developers/apps/building-github-apps) where permissions can be even better tuned. [Create a new app](https://docs.github.com/en/developers/apps/creating-a-github-app) and give it the following permissions:
| Permission | Level |
| --------------- | -------------- |
| `Contents` | `Read & write` |
| `Metadata` | `Read-only` |
| `Pull requests` | `Read & write` |
Store the app ID as a secret with name `APP_ID` and generate a new private key for the app and add it as a secret to the repository as `APP_PEM` in the repository where the action will run from. Note that `APP_PEM` needs to be base64 encoded. You can encode your private key file like this from the terminal:
```bash
cat your_app_key.pem | base64 -w 0 && echo
```
Going forward we will be using the [machine-learning-apps/actions-app-token](https://github.com/machine-learning-apps/actions-app-token) action in order to exchange the GitHub App certificate for an access token that renovate can use.
The final workflow will look like this:
```yaml
name: Renovate
on:
schedule:
# The "*" (#42, asterisk) character has special semantics in YAML, so this
# string has to be quoted.
- cron: '0/15 * * * *'
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Get token
id: get_token
uses: machine-learning-apps/actions-app-token@master
with:
APP_PEM: ${{ secrets.APP_PEM }}
APP_ID: ${{ secrets.APP_ID }}
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Self-hosted Renovate
uses: renovatebot/github-action@v29.27.0
with:
configurationFile: example/renovate-config.js
token: 'x-access-token:${{ steps.get_token.outputs.app_token }}'
```
## Troubleshooting
### Debug logging
In case of issues, it's always a good idea to enable debug logging first.
To enable debug logging, add the environment variable `LOG_LEVEL: 'debug'` to the action:
```yml
- name: Self-hosted Renovate
uses: renovatebot/github-action@v29.27.0
with:
configurationFile: example/renovate-config.js
token: ${{ secrets.RENOVATE_TOKEN }}
env:
LOG_LEVEL: 'debug'
```
### Special token requirements when using the `github-actions` manager
If you want to use the `github-actions` [manager](https://docs.renovatebot.com/modules/manager/github-actions/) in Renovate, ensure that the `token` you provide contains the `workflow` scope.
Otherwise, GitHub does not allow Renovate to update worklow files and therefore it will be unable to create update PRs for affected packages (like `actions/checkout` or `renovatebot/github-action` itself).
+4 -6
View File
@@ -6,16 +6,14 @@ branding:
color: blue
inputs:
configurationFile:
description: |
Configuration file to configure Renovate. Either use this input or the
'RENOVATE_CONFIG_FILE' environment variable.
description: 'Configuration file to configure Renovate'
required: false
default: src/config.js
token:
description: |
GitHub personal access token that Renovate should use. This should be
configured using a Secret. Either use this input or the 'RENOVATE_TOKEN'
environment variable.
required: false
configured using a Secret.
required: true
runs:
using: node12
main: dist/index.js
+773 -2269
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -1,8 +1,8 @@
module.exports = {
branchPrefix: 'test-renovate/',
dryRun: true,
username: 'renovate-release',
gitAuthor: 'Renovate Bot <bot@renovateapp.com>',
logLevel: 'debug',
onboarding: false,
platform: 'github',
includeForks: true,
@@ -14,7 +14,7 @@ module.exports = {
packageRules: [
{
description: 'lockFileMaintenance',
matchUpdateTypes: [
updateTypes: [
'pin',
'digest',
'patch',
@@ -22,7 +22,7 @@ module.exports = {
'major',
'lockFileMaintenance',
],
dependencyDashboardApproval: false,
masterIssueApproval: false,
stabilityDays: 0,
},
],
-29
View File
@@ -1,29 +0,0 @@
{
"branchPrefix": "test-renovate/",
"dryRun": true,
"username": "renovate-release",
"gitAuthor": "Renovate Bot <bot@renovateapp.com>",
"onboarding": false,
"platform": "github",
"includeForks": true,
"repositories": [
"renovatebot/github-action",
"renovate-tests/cocoapods1",
"renovate-tests/gomod1"
],
"packageRules": [
{
"description": "lockFileMaintenance",
"matchUpdateTypes": [
"pin",
"digest",
"patch",
"minor",
"major",
"lockFileMaintenance"
],
"dependencyDashboardApproval": false,
"stabilityDays": 0
}
]
}
+4859
View File
File diff suppressed because it is too large. Load diff
+34 -33
View File
@@ -1,25 +1,23 @@
{
"name": "github-action",
"version": "30.2.2",
"version": "19.230.0",
"description": "GitHub Action to run Renovate self-hosted.",
"private": true,
"main": "src/index.ts",
"main": "dist/index.js",
"scripts": {
"format": "prettier --ignore-unknown --write \"**/*.*\"",
"build:dist": "cd src && ncc build ./index.ts -o ../dist",
"build": "cd src && ncc build ./index.ts -o ../dist",
"format": "prettier --write \"**/*.{js,jsx,vue,ts,css,less,scss,html,htm,json,md,markdown,yml,yaml}\"",
"format:file": "prettier --write",
"lint": "run-s lint-es",
"lint:fix": "run-s lint-es:fix",
"lint-es": "eslint .",
"lint-es:file": "eslint",
"lint-es:fix": "eslint --fix .",
"lint-es:file:fix": "eslint --fix",
"release:version": "ts-node src/get-version",
"release:commit": "git add --force dist",
"release:standard-version": "standard-version --release-as",
"release": "run-s build release:commit \"release:standard-version -- {1}\" --",
"build": "ncc build -o dist",
"start": "run-s build && node dist",
"prepare": "husky install"
"git:dist": "git add -f dist",
"lint": "concurrently npm:lint-es",
"lint:fix": "concurrently npm:lint-es:fix",
"lint-es": "eslint --ext .ts,.tsx,.js,.jsx,.json .",
"lint-es:file": "eslint --ext .ts,.tsx,.js,.jsx,.json",
"lint-es:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix .",
"lint-es:file:fix": "eslint --ext .ts,.tsx,.js,.jsx,.json --fix",
"start": "run-s build:dist && node dist",
"version": "run-s build:* git:*"
},
"repository": {
"type": "git",
@@ -32,25 +30,28 @@
},
"homepage": "https://github.com/renovatebot/github-action#readme",
"dependencies": {
"@actions/core": "1.6.0",
"@actions/exec": "1.1.0"
"@actions/core": "1.2.4",
"@actions/exec": "1.0.4"
},
"devDependencies": {
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@types/node": "13.13.52",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"@vercel/ncc": "0.33.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-json": "3.1.0",
"husky": "7.0.4",
"lint-staged": "11.2.6",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@types/node": "13.13.4",
"@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0",
"@zeit/ncc": "0.22.1",
"chalk-cli": "4.1.0",
"concurrently": "5.2.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-json": "2.1.1",
"eslint-plugin-prettier": "3.1.3",
"husky": "4.2.5",
"lint-staged": "10.2.2",
"next-standard-version": "2.1.2",
"npm-run-all": "4.1.5",
"prettier": "2.5.1",
"standard-version": "9.3.2",
"ts-node": "10.4.0",
"typescript": "4.5.2"
"prettier": "2.0.5",
"standard-version": "7.1.0",
"typescript": "3.8.3"
}
}
+2 -3
View File
@@ -1,15 +1,14 @@
class Docker {
readonly repository = 'renovate/renovate';
// renovate: datasource=docker depName=renovate/renovate versioning=docker
readonly tag = '30.2.2-slim';
readonly tagSuffix = '-slim';
readonly tag = '19.230.0';
image(): string {
return `${this.repository}:${this.tag}`;
}
version(): string {
return this.tag.replace(this.tagSuffix, '');
return this.tag;
}
}
-5
View File
@@ -1,5 +0,0 @@
import * as core from '@actions/core';
import Docker from './docker';
const docker = new Docker();
core.setOutput('version', docker.version());
+2 -3
View File
@@ -5,14 +5,13 @@ import Renovate from './renovate';
async function run(): Promise<void> {
try {
const input = new Input();
const renovate = new Renovate(input);
const renovate = new Renovate(input.configurationFile, input.token);
await renovate.runDockerContainer();
} catch (error) {
console.error(error);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
core.setFailed(error.message);
}
}
void run();
run();
+8 -86
View File
@@ -1,98 +1,20 @@
import * as core from '@actions/core';
import path from 'path';
interface EnvironmentVariable {
key: string;
value: string;
}
class Input {
readonly options = {
envRegex: /^(?:RENOVATE_\w+|LOG_LEVEL|GITHUB_COM_TOKEN)$/,
configurationFile: {
input: 'configurationFile',
env: 'RENOVATE_CONFIG_FILE',
optional: true,
},
token: {
input: 'token',
env: 'RENOVATE_TOKEN',
optional: false,
},
} as const;
readonly token: Readonly<EnvironmentVariable>;
private readonly _environmentVariables: Map<string, string>;
private readonly _configurationFile: Readonly<EnvironmentVariable>;
readonly configurationFile = core.getInput('configurationFile', {
required: true,
});
readonly token = core.getInput('token', { required: true });
constructor() {
this._environmentVariables = new Map(
Object.entries(process.env).filter(([key]) =>
this.options.envRegex.test(key)
)
);
this.token = this.get(
this.options.token.input,
this.options.token.env,
this.options.token.optional
);
this._configurationFile = this.get(
this.options.configurationFile.input,
this.options.configurationFile.env,
this.options.configurationFile.optional
);
this.validate();
}
configurationFile(): EnvironmentVariable | null {
if (this._configurationFile.value !== '') {
return {
key: this._configurationFile.key,
value: path.resolve(this._configurationFile.value),
};
validate(): void {
if (this.token === '') {
throw new Error('input.token MUST NOT be empty');
}
return null;
}
/**
* Convert to environment variables.
*
* @note The environment variables listed below are filtered out.
* - Token, available with the `token` property.
* - Configuration file, available with the `configurationFile()` method.
*/
toEnvironmentVariables(): EnvironmentVariable[] {
return [...this._environmentVariables].map(([key, value]) => ({
key,
value,
}));
}
private get(
input: string,
env: string,
optional: boolean
): EnvironmentVariable {
const fromInput = core.getInput(input);
const fromEnv = this._environmentVariables.get(env);
if (fromInput === '' && fromEnv === undefined && !optional) {
throw new Error(
[
`'${input}' MUST be passed using its input or the '${env}'`,
'environment variable',
].join(' ')
);
}
this._environmentVariables.delete(env);
if (fromInput !== '') {
return { key: env, value: fromInput };
}
return { key: env, value: fromEnv !== undefined ? fromEnv : '' };
}
}
export default Input;
export { EnvironmentVariable, Input };
+21 -65
View File
@@ -1,47 +1,33 @@
import Docker from './docker';
import { Input } from './input';
import { exec } from '@actions/exec';
import fs from 'fs';
import path from 'path';
class Renovate {
private dockerGroupName = 'docker';
private configFileEnv = 'RENOVATE_CONFIG_FILE';
private tokenEnv = 'RENOVATE_TOKEN';
private configFileMountDir = '/github-action';
private configFile: string;
private docker: Docker;
constructor(private input: Input) {
constructor(configFile: string, private token: string) {
this.configFile = path.resolve(configFile);
this.validateArguments();
this.docker = new Docker();
}
async runDockerContainer(): Promise<void> {
const renovateDockerUser = '1000';
const dockerArguments = this.input
.toEnvironmentVariables()
.map((e) => `--env ${e.key}`)
.concat([`--env ${this.input.token.key}=${this.input.token.value}`]);
if (this.input.configurationFile() !== null) {
const baseName = path.basename(this.input.configurationFile().value);
const mountPath = path.join(this.configFileMountDir, baseName);
dockerArguments.push(
`--env ${this.input.configurationFile().key}=${mountPath}`,
`--volume ${this.input.configurationFile().value}:${mountPath}`
);
}
dockerArguments.push(
'--volume /var/run/docker.sock:/var/run/docker.sock',
'--volume /tmp:/tmp',
`--user ${renovateDockerUser}:${this.getDockerGroupId()}`,
const commandArguments = [
'--rm',
this.docker.image()
);
const command = `docker run ${dockerArguments.join(' ')}`;
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
`--env ${this.tokenEnv}=${this.token}`,
`--volume ${this.configFile}:${this.configFileMountPath()}`,
this.docker.image(),
];
const command = `docker run ${commandArguments.join(' ')}`;
const code = await exec(command);
if (code !== 0) {
@@ -49,50 +35,20 @@ class Renovate {
}
}
/**
* Fetch the host docker group of the GitHub Action runner.
*
* The Renovate container needs access to this group in order to have the
* required permissions on the Docker socket.
*/
private getDockerGroupId(): string {
const groupFile = '/etc/group';
const groups = fs.readFileSync(groupFile, {
encoding: 'utf-8',
});
/**
* The group file has `groupname:group-password:GID:username-list` as
* structure and we're interested in the `GID` (the group ID).
*
* Source: https://www.thegeekdiary.com/etcgroup-file-explained/
*/
const re = new RegExp(`^${this.dockerGroupName}:x:([1-9][0-9]*):`, 'm');
const match = re.exec(groups);
if (!match || match.length < 2) {
private validateArguments(): void {
if (!fs.existsSync(this.configFile)) {
throw new Error(
`Could not find group '${this.dockerGroupName}' in ${groupFile}`
`Could not locate configuration file '${this.configFile}'.`
);
}
return match[1];
}
private validateArguments(): void {
if (/\s/.test(this.input.token.value)) {
throw new Error('Token MUST NOT contain whitespace');
}
private configFileName(): string {
return path.basename(this.configFile);
}
const configurationFile = this.input.configurationFile();
if (
configurationFile !== null &&
(!fs.existsSync(configurationFile.value) ||
!fs.statSync(configurationFile.value).isFile())
) {
throw new Error(
`configuration file '${configurationFile.value}' MUST be an existing file`
);
}
private configFileMountPath(): string {
return path.join(this.configFileMountDir, this.configFileName());
}
}
-1
View File
@@ -3,7 +3,6 @@
"compilerOptions": {
"sourceMap": false,
"declaration": false,
"allowJs": false,
"rootDir": ".",
"outDir": "dist",
"types": ["node"]
-4
View File
@@ -1,4 +0,0 @@
{
"extends": "./tsconfig.json",
"include": ["**/*.js", "**/*.ts", "**/*.d.ts", ".*.js"]
}
+3 -2
View File
@@ -6,7 +6,8 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"outDir": "dist"
}
},
"include": ["src/**/*.ts", "bin/**/*.ts"],
"exclude": ["node_modules", "**/*.test.ts"]
}
-3108
View File
File diff suppressed because it is too large. Load diff