├── .editorconfig ├── .gitattributes ├── .github ├── actions │ └── setup-node │ │ └── action.yml ├── renovate.json └── workflows │ └── build.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .lintstagedrc.json ├── .node-version ├── .npmrc ├── .prettierignore ├── .prettierrc.json ├── .releaserc.json ├── CHANGELOG.md ├── README.md ├── action.yml ├── commitlint.config.js ├── eslint.config.js ├── example ├── entrypoint.sh ├── renovate-config.js └── renovate-config.json ├── license ├── package.json ├── pnpm-lock.yaml ├── src ├── docker.ts ├── index.ts ├── input.ts └── renovate.ts ├── tools ├── cjs-shim.ts ├── compile.js └── tsconfig.json ├── tsconfig.dist.json └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/actions/setup-node/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup Node.js' 2 | description: 'Setup Node and install dependencies using cache' 3 | inputs: 4 | save-cache: 5 | description: 'Save cache when needed' 6 | required: false 7 | default: 'false' 8 | 9 | runs: 10 | using: 'composite' 11 | 12 | steps: 13 | - name: ⚙️ Calculate `CACHE_KEY` 14 | shell: bash 15 | run: | 16 | echo 'CACHE_KEY=node_modules-${{ 17 | hashFiles('.node-version', 'pnpm-lock.yaml') 18 | }}' >> "$GITHUB_ENV" 19 | 20 | - name: ♻️ Restore `node_modules` 21 | uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 22 | id: node-modules-restore 23 | with: 24 | path: node_modules 25 | key: ${{ env.CACHE_KEY }} 26 | enableCrossOsArchive: true 27 | 28 | - name: Calculate `CACHE_HIT` 29 | shell: bash 30 | run: | 31 | echo 'CACHE_HIT=${{ 32 | (steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || '' 33 | }}' >> "$GITHUB_ENV" 34 | 35 | - name: ⚙️ Setup pnpm 36 | uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 37 | with: 38 | standalone: true 39 | 40 | - name: ⚙️ Setup Node.js ${{ inputs.node-version }} 41 | uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 42 | with: 43 | node-version-file: .node-version 44 | cache: ${{ env.CACHE_HIT != 'true' && 'pnpm' || '' }} 45 | 46 | - name: 📥 Install dependencies 47 | if: env.CACHE_HIT != 'true' 48 | shell: bash 49 | run: pnpm install --frozen-lockfile 50 | env: 51 | # Other environment variables 52 | HUSKY: '0' # By default do not run HUSKY install 53 | 54 | - name: ♻️ Write `node_modules` cache 55 | if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true' 56 | uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 57 | with: 58 | path: node_modules 59 | key: ${{ env.CACHE_KEY }} 60 | enableCrossOsArchive: true 61 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["github>renovatebot/.github", ":pinDependencies"], 4 | "packageRules": [ 5 | { 6 | "description": "Update references in Markdown files weekly", 7 | "matchFileNames": ["**/*.md"], 8 | "extends": ["schedule:weekly"], 9 | "automerge": true, 10 | "minimumReleaseAge": null, 11 | "separateMajorMinor": false, 12 | "commitMessageTopic": "references to {{{depName}}}", 13 | "semanticCommitType": "docs", 14 | "semanticCommitScope": null, 15 | "additionalBranchPrefix": "docs-" 16 | }, 17 | { 18 | "description": "Use build semantic type for some deps", 19 | "matchPackageNames": ["@vercel/ncc", "typescript"], 20 | "semanticCommitType": "build" 21 | }, 22 | { 23 | "description": "Use `build` semantic commit scope for lockfile maintenance", 24 | "matchUpdateTypes": ["lockFileMaintenance"], 25 | "semanticCommitType": "build" 26 | }, 27 | { 28 | "description": "Use ci semantic type for some deps", 29 | "matchFileNames": [".github/workflows/**"], 30 | "semanticCommitType": "ci" 31 | }, 32 | { 33 | "description": "Don't require approval for renovate", 34 | "matchPackageNames": [ 35 | "ghcr.io/renovatebot/renovate", 36 | "renovatebot/github-action" 37 | ], 38 | "dependencyDashboardApproval": false 39 | }, 40 | { 41 | "description": "Don't pin renovate updates", 42 | "matchPackageNames": ["ghcr.io/renovatebot/renovate"], 43 | "matchFileNames": ["action.yml", "src/docker.ts"], 44 | "pinDigests": false 45 | }, 46 | { 47 | "description": "Use feat! semantic type for renovate major", 48 | "matchPackageNames": ["ghcr.io/renovatebot/renovate"], 49 | "matchFileNames": ["action.yml", "src/docker.ts"], 50 | "matchUpdateTypes": ["major"], 51 | "commitMessagePrefix": "feat(deps)!:", 52 | "additionalBranchPrefix": "renovate-major" 53 | } 54 | ], 55 | "customManagers": [ 56 | { 57 | "customType": "regex", 58 | "fileMatch": ["^README\\.md$"], 59 | "matchStrings": [ 60 | "uses: renovatebot/github-action@(?[^\\s]+)" 61 | ], 62 | "depNameTemplate": "renovatebot/github-action", 63 | "datasourceTemplate": "github-releases" 64 | }, 65 | { 66 | "customType": "regex", 67 | "fileMatch": ["^README\\.md$"], 68 | "matchStrings": ["renovate-version: (?[^\\s]+)"], 69 | "depNameTemplate": "ghcr.io/renovatebot/renovate", 70 | "datasourceTemplate": "docker" 71 | }, 72 | { 73 | "description": "Update renovate version in action.yml", 74 | "customType": "regex", 75 | "fileMatch": ["^action\\.yml$"], 76 | "matchStrings": ["default: '(?[^\\s]+)' # renovate"], 77 | "depNameTemplate": "ghcr.io/renovatebot/renovate", 78 | "datasourceTemplate": "docker" 79 | }, 80 | { 81 | "description": "Update renovate version in src/docker.ts", 82 | "customType": "regex", 83 | "fileMatch": ["^src/docker\\.ts$"], 84 | "matchStrings": ["version = '(?[^\\s]+)'; // renovate"], 85 | "depNameTemplate": "ghcr.io/renovatebot/renovate", 86 | "datasourceTemplate": "docker" 87 | } 88 | ] 89 | } 90 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.event.number || github.ref }} 10 | cancel-in-progress: true 11 | 12 | env: 13 | RENOVATE_VERSION: 40.36.8 # renovate: datasource=docker depName=renovate packageName=ghcr.io/renovatebot/renovate 14 | 15 | jobs: 16 | prepare: 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 10 19 | 20 | steps: 21 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 22 | with: 23 | show-progress: false 24 | 25 | - name: 📥 Setup Node.js 26 | uses: ./.github/actions/setup-node 27 | with: 28 | save-cache: true 29 | 30 | commitlint: 31 | runs-on: ubuntu-latest 32 | if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }} 33 | 34 | steps: 35 | - name: Checkout 36 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 37 | with: 38 | fetch-depth: 0 39 | show-progress: false 40 | filter: blob:none # we don't need all blobs, only the full tree 41 | 42 | - name: Lint commit messages 43 | uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 44 | continue-on-error: true 45 | 46 | lint: 47 | needs: 48 | - prepare 49 | runs-on: ubuntu-latest 50 | if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }} 51 | 52 | steps: 53 | - name: Checkout 54 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 55 | with: 56 | show-progress: false 57 | 58 | - name: 📥 Setup Node.js 59 | uses: ./.github/actions/setup-node 60 | 61 | - name: Lint 62 | run: pnpm lint 63 | 64 | e2e: 65 | needs: 66 | - prepare 67 | runs-on: ubuntu-latest 68 | if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }} 69 | 70 | strategy: 71 | fail-fast: false 72 | matrix: 73 | configurationFile: 74 | - example/renovate-config.js 75 | - example/renovate-config.json 76 | steps: 77 | - name: Checkout 78 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 79 | with: 80 | show-progress: false 81 | 82 | - name: 📥 Setup Node.js 83 | uses: ./.github/actions/setup-node 84 | 85 | - name: Build 86 | run: pnpm build 87 | 88 | - name: Configure renovate token 89 | run: | 90 | if [[ "${RENOVATE_TOKEN}" != "" ]]; then 91 | echo "RENOVATE_TOKEN=${RENOVATE_TOKEN}" >> $GITHUB_ENV 92 | else 93 | echo "RENOVATE_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV 94 | fi 95 | env: 96 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 97 | RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} 98 | 99 | - name: Renovate test 100 | uses: ./ 101 | env: 102 | LOG_LEVEL: debug 103 | with: 104 | configurationFile: ${{ matrix.configurationFile }} 105 | 106 | - name: Renovate test with entrypoint 107 | uses: ./ 108 | env: 109 | LOG_LEVEL: debug 110 | with: 111 | configurationFile: ${{ matrix.configurationFile }} 112 | renovate-version: ${{ env.RENOVATE_VERSION }} 113 | docker-cmd-file: example/entrypoint.sh 114 | docker-user: root 115 | 116 | release: 117 | needs: 118 | - lint 119 | - commitlint 120 | - e2e 121 | runs-on: ubuntu-latest 122 | steps: 123 | - name: Setup Git user 124 | shell: bash 125 | run: | 126 | git config --global core.autocrlf false 127 | git config --global core.symlinks true 128 | git config --global user.name "github-actions[bot]" 129 | git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" 130 | 131 | - name: Checkout 132 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 133 | with: 134 | fetch-depth: 0 # required for semantic release 135 | ref: 'release' 136 | show-progress: false 137 | filter: blob:none # we don't need all blobs, only the full tree 138 | 139 | - name: fetch pr 140 | if: ${{github.event_name == 'pull_request'}} 141 | run: git fetch origin +${{ github.sha }}:${{ github.ref }} 142 | 143 | - name: Merge main 144 | id: merge 145 | run: | 146 | git merge --no-ff -Xtheirs -m 'skip: merge (${{ github.sha }}) [skip release]' ${{ github.sha }} 147 | commit=$(git rev-parse HEAD) 148 | 149 | - name: 📥 Setup Node.js 150 | uses: ./.github/actions/setup-node 151 | 152 | - name: Push release branch 153 | run: git push origin release:release 154 | if: ${{ github.ref_name == github.event.repository.default_branch }} 155 | 156 | - name: Release 157 | run: | 158 | # override for semantic-release 159 | export GITHUB_REF=refs/heads/release GITHUB_SHA=${{ steps.merge.outputs.commit }} 160 | pnpm release 161 | if: ${{ github.ref_name == github.event.repository.default_branch }} 162 | env: 163 | GITHUB_TOKEN: ${{ github.token }} 164 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ##################################################### 2 | # macOS # 3 | # Source: https://www.gitignore.io # 4 | ##################################################### 5 | # General 6 | .DS_Store 7 | .AppleDouble 8 | .LSOverride 9 | 10 | # Icon must end with two \r 11 | Icon 12 | 13 | # Thumbnails 14 | ._* 15 | 16 | # Files that might appear in the root of a volume 17 | .DocumentRevisions-V100 18 | .fseventsd 19 | .Spotlight-V100 20 | .TemporaryItems 21 | .Trashes 22 | .VolumeIcon.icns 23 | .com.apple.timemachine.donotpresent 24 | 25 | # Directories potentially created on remote AFP share 26 | .AppleDB 27 | .AppleDesktop 28 | Network Trash Folder 29 | Temporary Items 30 | .apdisk 31 | 32 | 33 | ##################################################### 34 | # Linux # 35 | # Source: https://www.gitignore.io # 36 | ##################################################### 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | 52 | ##################################################### 53 | # Windows # 54 | # Source: https://www.gitignore.io # 55 | ##################################################### 56 | # Windows thumbnail cache files 57 | Thumbs.db 58 | Thumbs.db:encryptable 59 | ehthumbs.db 60 | ehthumbs_vista.db 61 | 62 | # Dump file 63 | *.stackdump 64 | 65 | # Folder config file 66 | [Dd]esktop.ini 67 | 68 | # Recycle Bin used on file shares 69 | $RECYCLE.BIN/ 70 | 71 | # Windows Installer files 72 | *.cab 73 | *.msi 74 | *.msix 75 | *.msm 76 | *.msp 77 | 78 | # Windows shortcuts 79 | *.lnk 80 | 81 | 82 | ##################################################### 83 | # dotenv # 84 | ##################################################### 85 | .env 86 | 87 | 88 | ##################################################### 89 | # CMake # 90 | # Source: https://www.gitignore.io # 91 | ##################################################### 92 | CMakeLists.txt.user 93 | CMakeCache.txt 94 | CMakeFiles 95 | CMakeScripts 96 | Testing 97 | Makefile 98 | cmake_install.cmake 99 | install_manifest.txt 100 | compile_commands.json 101 | CTestTestfile.cmake 102 | _deps 103 | 104 | ### CMake Patch ### 105 | # External projects 106 | *-prefix/ 107 | 108 | 109 | ##################################################### 110 | # Node # 111 | # Source: https://www.gitignore.io # 112 | ##################################################### 113 | # Logs 114 | logs 115 | *.log 116 | npm-debug.log* 117 | yarn-debug.log* 118 | yarn-error.log* 119 | lerna-debug.log* 120 | 121 | # Diagnostic reports (https://nodejs.org/api/report.html) 122 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 123 | 124 | # Runtime data 125 | pids 126 | *.pid 127 | *.seed 128 | *.pid.lock 129 | 130 | # Directory for instrumented libs generated by jscoverage/JSCover 131 | lib-cov 132 | 133 | # Coverage directory used by tools like istanbul 134 | coverage 135 | *.lcov 136 | 137 | # nyc test coverage 138 | .nyc_output 139 | 140 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 141 | .grunt 142 | 143 | # Bower dependency directory (https://bower.io/) 144 | bower_components 145 | 146 | # node-waf configuration 147 | .lock-wscript 148 | 149 | # Compiled binary addons (https://nodejs.org/api/addons.html) 150 | build/Release 151 | 152 | # Dependency directories 153 | node_modules/ 154 | jspm_packages/ 155 | 156 | # TypeScript v1 declaration files 157 | typings/ 158 | 159 | # TypeScript cache 160 | *.tsbuildinfo 161 | 162 | # Optional npm cache directory 163 | .npm 164 | 165 | # Optional eslint cache 166 | .eslintcache 167 | 168 | # Optional REPL history 169 | .node_repl_history 170 | 171 | # Output of 'npm pack' 172 | *.tgz 173 | 174 | # Yarn Integrity file 175 | .yarn-integrity 176 | 177 | # dotenv environment variables file 178 | .env 179 | .env.test 180 | 181 | # parcel-bundler cache (https://parceljs.org/) 182 | .cache 183 | 184 | # next.js build output 185 | .next 186 | 187 | # nuxt.js build output 188 | .nuxt 189 | 190 | # react / gatsby 191 | public/ 192 | 193 | # vuepress build output 194 | .vuepress/dist 195 | 196 | # Serverless directories 197 | .serverless/ 198 | 199 | # FuseBox cache 200 | .fusebox/ 201 | 202 | # DynamoDB Local files 203 | .dynamodb/ 204 | 205 | # Typescript output directories 206 | dist/ 207 | 208 | 209 | ##################################################### 210 | # C # 211 | # Source: https://www.gitignore.io # 212 | ##################################################### 213 | # Prerequisites 214 | *.d 215 | 216 | # Object files 217 | *.o 218 | *.ko 219 | *.obj 220 | *.elf 221 | 222 | # Linker output 223 | *.ilk 224 | *.map 225 | *.exp 226 | 227 | # Precompiled Headers 228 | *.gch 229 | *.pch 230 | 231 | # Libraries 232 | *.lib 233 | *.a 234 | *.la 235 | *.lo 236 | 237 | # Shared objects (inc. Windows DLLs) 238 | *.dll 239 | *.so 240 | *.so.* 241 | *.dylib 242 | 243 | # Executables 244 | *.exe 245 | *.out 246 | *.app 247 | *.i*86 248 | *.x86_64 249 | *.hex 250 | 251 | # Debug files 252 | *.dSYM/ 253 | *.su 254 | *.idb 255 | *.pdb 256 | 257 | # Kernel Module Compile Results 258 | *.mod* 259 | *.cmd 260 | .tmp_versions/ 261 | modules.order 262 | Module.symvers 263 | Mkfile.old 264 | dkms.conf 265 | 266 | 267 | ##################################################### 268 | # C++ # 269 | # Source: https://www.gitignore.io # 270 | ##################################################### 271 | # Prerequisites 272 | *.d 273 | 274 | # Compiled Object files 275 | *.slo 276 | *.lo 277 | *.o 278 | *.obj 279 | 280 | # Precompiled Headers 281 | *.gch 282 | *.pch 283 | 284 | # Compiled Dynamic libraries 285 | *.so 286 | *.dylib 287 | *.dll 288 | 289 | # Fortran module files 290 | *.mod 291 | *.smod 292 | 293 | # Compiled Static libraries 294 | *.lai 295 | *.la 296 | *.a 297 | *.lib 298 | 299 | # Executables 300 | *.exe 301 | *.out 302 | *.app 303 | 304 | 305 | /.pnpm-store 306 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | commitlint --edit "$1" 4 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | lint-staged 4 | -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.{ts,tsx,js,jsx,json}": [ 3 | "eslint --cache --fix", 4 | "prettier --cache --write" 5 | ], 6 | "!*.{ts,tsx,js,jsx,json}": "prettier --cache --ignore-unknown --write" 7 | } 8 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 20.19.2 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact=true 2 | save-prefix = 3 | 4 | # pnpm run settings 5 | # https://pnpm.io/cli/run 6 | shell-emulator = true 7 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .vscode 3 | build/ 4 | dist/ 5 | coverage/ 6 | LICENSE.md 7 | modules/ 8 | node_modules/ 9 | 10 | /.pnpm-store 11 | /pnpm-lock.yaml 12 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all", 4 | "plugins": ["prettier-plugin-packagejson"] 5 | } 6 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "branches": ["release"], 3 | "plugins": [ 4 | "@semantic-release/commit-analyzer", 5 | "@semantic-release/release-notes-generator", 6 | "@semantic-release/npm", 7 | [ 8 | "@semantic-release/git", 9 | { 10 | "assets": ["dist", "package.json"], 11 | "message": "chore(release): ${nextRelease.version} [skip ci]" 12 | } 13 | ], 14 | [ 15 | "@semantic-release/github", 16 | { 17 | "releasedLabels": false, 18 | "successComment": false 19 | } 20 | ] 21 | ], 22 | "analyzeCommits": { 23 | "releaseRules": [ 24 | { 25 | "type": "docs", 26 | "scope": "readme.md", 27 | "release": "patch" 28 | }, 29 | { 30 | "type": "build", 31 | "release": "patch" 32 | }, 33 | { 34 | "type": "skip", 35 | "release": false 36 | } 37 | ] 38 | }, 39 | "preset": "conventionalcommits", 40 | "presetConfig": { 41 | "types": [ 42 | { 43 | "type": "feat", 44 | "section": "Features" 45 | }, 46 | { 47 | "type": "feature", 48 | "section": "Features" 49 | }, 50 | { 51 | "type": "fix", 52 | "section": "Bug Fixes" 53 | }, 54 | { 55 | "type": "perf", 56 | "section": "Performance Improvements" 57 | }, 58 | { 59 | "type": "revert", 60 | "section": "Reverts" 61 | }, 62 | { 63 | "type": "docs", 64 | "section": "Documentation" 65 | }, 66 | { 67 | "type": "style", 68 | "section": "Styles" 69 | }, 70 | { 71 | "type": "chore", 72 | "section": "Miscellaneous Chores" 73 | }, 74 | { 75 | "type": "refactor", 76 | "section": "Code Refactoring" 77 | }, 78 | { 79 | "type": "test", 80 | "section": "Tests" 81 | }, 82 | { 83 | "type": "build", 84 | "section": "Build System" 85 | }, 86 | { 87 | "type": "ci", 88 | "section": "Continuous Integration" 89 | }, 90 | { 91 | "type": "skip", 92 | "hidden": true 93 | } 94 | ] 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | You can find the changelogs on the [GitHub releases page for `renovatebot/github-action`](https://github.com/renovatebot/github-action/releases/). 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action Renovate 2 | 3 | GitHub Action to run Renovate self-hosted. 4 | 5 | 6 | 7 | 8 | 9 | ## Table of contents 10 | 11 | - [Badges](#badges) 12 | - [Options](#options) 13 | - [`configurationFile`](#configurationfile) 14 | - [`docker-cmd-file`](#docker-cmd-file) 15 | - [`docker-network`](#docker-network) 16 | - [`docker-socket-host-path`](#docker-socket-host-path) 17 | - [`docker-user`](#docker-user) 18 | - [`docker-volumes`](#docker-volumes) 19 | - [`env-regex`](#env-regex) 20 | - [`mount-docker-socket`](#mount-docker-socket) 21 | - [`token`](#token) 22 | - [`renovate-image`](#renovate-image) 23 | - [`renovate-version`](#renovate-version) 24 | - [Example](#example) 25 | - [Environment Variables](#environment-variables) 26 | - [Passing other environment variables](#passing-other-environment-variables) 27 | - [Persisting the Repository Cache](#persisting-the-repository-cache) 28 | - [Troubleshooting](#troubleshooting) 29 | - [Debug Logging](#debug-logging) 30 | - [Special token requirements when using the `github-actions` manager](#special-token-requirements-when-using-the-github-actions-manager) 31 | 32 | ## Badges 33 | 34 | | Badge | Description | Service | 35 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | -------------------- | 36 | | code style | Code style | Prettier | 37 | | Conventional Commits: 1.0.0 | Commit style | Conventional Commits | 38 | | Renovate enabled | Dependencies | Renovate | 39 | | GitHub workflow status | Build | GitHub Actions | 40 | 41 | ## Options 42 | 43 | Options can be passed using the inputs of this action or the corresponding environment variables. 44 | When both are passed, the input takes precedence over the environment variable. 45 | For the available environment variables, see the Renovate [Self-Hosted Configuration](https://docs.renovatebot.com/self-hosted-configuration/) docs. 46 | 47 | ### `configurationFile` 48 | 49 | Configuration file to configure Renovate ("global" config) in JavaScript or JSON format. 50 | It is recommended to not name it one of the repository configuration filenames listed in the Renovate Docs for [Configuration Options](https://docs.renovatebot.com/configuration-options/). 51 | 52 | Config examples can be found in the [example](./example) directory. 53 | 54 | The configurations that can be done in this file consists of two parts, as listed below. 55 | Refer to the links to the [Renovate Docs](https://docs.renovatebot.com/) for all options. 56 | 57 | 1. [Self-Hosted Configuration Options](https://docs.renovatebot.com/self-hosted-configuration/) 58 | 2. [Configuration Options](https://docs.renovatebot.com/configuration-options/) 59 | 60 | The [`branchPrefix`](https://docs.renovatebot.com/configuration-options/#branchprefix) option is important to configure and should be configured to a value other than the default to prevent interference with e.g. the Renovate GitHub App. 61 | 62 | If you want to use this with just the single configuration file, make sure to include the following two configuration lines. 63 | This disables the requirement of a configuration file for the repository and disables onboarding. 64 | 65 | ```js 66 | onboarding: false, 67 | requireConfig: 'optional', 68 | ``` 69 | 70 | ### `docker-cmd-file` 71 | 72 | Specify a command to run when the image start. 73 | By default the image run 74 | `renovate`. 75 | This option is useful to customize the image before running `renovate`. 76 | It must be an existing executable file on the local system. 77 | It will be mounted to the docker container. 78 | 79 | For example you can create a simple script like this one (let's call it 80 | `renovate-entrypoint.sh`). 81 | 82 | ```sh 83 | #!/bin/bash 84 | 85 | apt update 86 | 87 | apt install -y build-essential libpq-dev 88 | 89 | runuser -u ubuntu renovate 90 | ``` 91 | 92 | Now use this action 93 | 94 | ```yml 95 | .... 96 | jobs: 97 | renovate: 98 | runs-on: ubuntu-latest 99 | steps: 100 | - name: Checkout 101 | uses: actions/checkout@v4.2.2 102 | - name: Self-hosted Renovate 103 | uses: renovatebot/github-action@v42.0.3 104 | with: 105 | docker-cmd-file: .github/renovate-entrypoint.sh 106 | docker-user: root 107 | token: ${{ secrets.RENOVATE_TOKEN }} 108 | ``` 109 | 110 | ### `docker-network` 111 | 112 | Specify a network to run container in. 113 | 114 | You can use `${{ job.container.network }}` to run renovate container [in the same network as other containers for this job](https://docs.github.com/en/actions/learn-github-actions/contexts#job-context), 115 | or set it to `host` to run in the same network as github runner, or specify any custom network. 116 | 117 | ### `docker-socket-host-path` 118 | 119 | Allows the overriding of the host path for the Docker socket that is mounted into the container. 120 | Useful on systems where the host Docker socket is located somewhere other than `/var/run/docker.sock` (the default). 121 | Only applicable when `mount-docker-socket` is true. 122 | 123 | ### `docker-user` 124 | 125 | Specify a user (or user-id) to run docker command. 126 | 127 | You can use it with [`docker-cmd-file`](#docker-cmd-file) in order to start the 128 | image as root, do some customization and switch back to a unprivileged user. 129 | 130 | ### `docker-volumes` 131 | 132 | Specify volume mounts. Defaults to `/tmp:/tmp`. 133 | The volume mounts are separated through `;`. 134 | 135 | This sample will mount `/tmp:/tmp` and `/foo:/bar`. 136 | 137 | ```yml 138 | .... 139 | jobs: 140 | renovate: 141 | runs-on: ubuntu-latest 142 | steps: 143 | - name: Checkout 144 | uses: actions/checkout@v4.2.2 145 | - name: Self-hosted Renovate 146 | uses: renovatebot/github-action@v42.0.3 147 | with: 148 | token: ${{ secrets.RENOVATE_TOKEN }} 149 | docker-volumes: | 150 | /tmp:/tmp ; 151 | /foo:/bar 152 | ``` 153 | 154 | ### `env-regex` 155 | 156 | Allows to configure the regex to define which environment variables are passed to the renovate container. 157 | See [Passing other environment variables](#passing-other-environment-variables) section for more details. 158 | 159 | ## `mount-docker-socket` 160 | 161 | Default to `false`. If set to `true` the action will mount the Docker socket 162 | inside the renovate container so that the commands can use Docker. Can be useful 163 | for `postUpgradeTasks`'s commands. Also add the user inside the renovate 164 | container to the docker group for socket permissions. 165 | 166 | ### `token` 167 | 168 | [Generate a Personal Access Token (classic)](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`. 169 | You can also create a token without a specific scope, which gives read-only access to public repositories, for testing. 170 | 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. 171 | The name of the secret can be anything as long as it matches the argument given to the `token` option. 172 | 173 | Note that Renovate _cannot_ currently use [Fine-grained Personal Access Tokens](https://github.com/settings/tokens?type=beta) since they do not support the GitHub GraphQL API, yet. 174 | 175 | 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 because it has too restrictive permissions. 176 | In particular, using the `GITHUB_TOKEN` to create a new `Pull Request` from more types of Github Workflows results in `Pull Requests` that [do not trigger your `Pull Request` and `Push` CI events](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow). 177 | 178 | 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. 179 | 180 | ### `renovate-image` 181 | 182 | The Renovate Docker image name to use. 183 | If omitted the action will use the `ghcr.io/renovatebot/renovate:` Docker image name otherwise. 184 | If a Docker image name is defined, the action will use that name to pull the image. 185 | 186 | This sample will use `myproxyhub.domain.com/renovate/renovate:` image. 187 | 188 | ```yml 189 | .... 190 | jobs: 191 | renovate: 192 | runs-on: ubuntu-latest 193 | steps: 194 | - name: Checkout 195 | uses: actions/checkout@v4.2.2 196 | - name: Self-hosted Renovate 197 | uses: renovatebot/github-action@v42.0.3 198 | with: 199 | renovate-image: myproxyhub.domain.com/renovate/renovate 200 | token: ${{ secrets.RENOVATE_TOKEN }} 201 | ``` 202 | 203 | This sample will use `ghcr.io/renovatebot/renovate:` image. 204 | 205 | ```yml 206 | .... 207 | jobs: 208 | renovate: 209 | runs-on: ubuntu-latest 210 | steps: 211 | - name: Checkout 212 | uses: actions/checkout@v4.2.2 213 | - name: Self-hosted Renovate 214 | uses: renovatebot/github-action@v42.0.3 215 | with: 216 | token: ${{ secrets.RENOVATE_TOKEN }} 217 | ``` 218 | 219 | ### `renovate-version` 220 | 221 | The Renovate version to use. 222 | If omitted the action will use the [`default version`](./action.yml#L28) Docker tag. 223 | Check [the available tags on Docker Hub](https://hub.docker.com/r/renovate/renovate/tags). 224 | 225 | This sample will use `ghcr.io/renovatebot/renovate:40.31.0` image. 226 | 227 | ```yml 228 | .... 229 | jobs: 230 | renovate: 231 | runs-on: ubuntu-latest 232 | steps: 233 | - name: Checkout 234 | uses: actions/checkout@v4.2.2 235 | - name: Self-hosted Renovate 236 | uses: renovatebot/github-action@v42.0.3 237 | with: 238 | renovate-version: 40.31.0 239 | token: ${{ secrets.RENOVATE_TOKEN }} 240 | ``` 241 | 242 | This sample will use `ghcr.io/renovatebot/renovate:full` image. 243 | 244 | ```yml 245 | .... 246 | jobs: 247 | renovate: 248 | runs-on: ubuntu-latest 249 | steps: 250 | - name: Checkout 251 | uses: actions/checkout@v4.2.2 252 | - name: Self-hosted Renovate 253 | uses: renovatebot/github-action@v42.0.3 254 | with: 255 | renovate-version: full 256 | token: ${{ secrets.RENOVATE_TOKEN }} 257 | ``` 258 | 259 | We recommend you pin the version of Renovate to a full version or a full checksum, and use Renovate's regex manager to create PRs to update the pinned version. 260 | See `.github/workflows/build.yml` for an example of how to do this. 261 | 262 | ## Example 263 | 264 | This example uses a Personal Access Token and will run every 15 minutes. 265 | The Personal Access token is configured as a GitHub secret named `RENOVATE_TOKEN`. 266 | This example uses the [`example/renovate-config.js`](./example/renovate-config.js) file as configuration. 267 | Live examples with more advanced configurations of this action can be found in the following repositories: 268 | 269 | - [vidavidorra/renovate](https://github.com/vidavidorra/renovate/blob/main/.github/renovate.json) 270 | - [jenkinsci/helm-charts](https://github.com/jenkinsci/helm-charts/blob/main/.github/renovate-config.json5) 271 | 272 | **Remark** Update the action version to the most current, see [here](https://github.com/renovatebot/github-action/releases/latest) for latest release. 273 | 274 | ```yml 275 | name: Renovate 276 | on: 277 | schedule: 278 | # The "*" (#42, asterisk) character has special semantics in YAML, so this 279 | # string has to be quoted. 280 | - cron: '0/15 * * * *' 281 | jobs: 282 | renovate: 283 | runs-on: ubuntu-latest 284 | steps: 285 | - name: Checkout 286 | uses: actions/checkout@v4.2.2 287 | - name: Self-hosted Renovate 288 | uses: renovatebot/github-action@v42.0.3 289 | with: 290 | configurationFile: example/renovate-config.js 291 | token: ${{ secrets.RENOVATE_TOKEN }} 292 | ``` 293 | 294 | ### Example for GitHub Enterprise 295 | 296 | If you want to use the Renovate Action on a GitHub Enterprise instance you have to add the following environment variable: 297 | 298 | ```yml 299 | .... 300 | - name: Self-hosted Renovate 301 | uses: renovatebot/github-action@v42.0.3 302 | with: 303 | configurationFile: example/renovate-config.js 304 | token: ${{ secrets.RENOVATE_TOKEN }} 305 | env: 306 | RENOVATE_ENDPOINT: "https://git.your-company.com/api/v3" 307 | ``` 308 | 309 | ### Example with GitHub App 310 | 311 | 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. 312 | [Create a new app](https://docs.github.com/en/developers/apps/creating-a-github-app) and configure the app permissions and your `config.js` as described in the [Renovate documentation](https://docs.renovatebot.com/modules/platform/github/#running-as-a-github-app). 313 | 314 | Generate and download a new private key for the app, adding the contents of the downloaded `.pem` file to _Secrets_ (repository settings) with the name `private_key` and app ID as a secret with name `app_id`. 315 | 316 | Adjust your Renovate configuration file to specify the username of your bot. 317 | 318 | From the Github app configuration page, install the app in your account or your organization's account, and configure the repository access. 319 | 320 | Going forward we will be using the [`actions/create-github-app-token` action](https://github.com/actions/create-github-app-token) in order to exchange the GitHub App certificate for an access token that Renovate can use. 321 | 322 | The final workflow will look like this: 323 | 324 | ```yaml 325 | name: Renovate 326 | on: 327 | schedule: 328 | # The "*" (#42, asterisk) character has special semantics in YAML, so this 329 | # string has to be quoted. 330 | - cron: '0/15 * * * *' 331 | jobs: 332 | renovate: 333 | runs-on: ubuntu-latest 334 | steps: 335 | - name: Get token 336 | id: get_token 337 | uses: actions/create-github-app-token@v1 338 | with: 339 | private-key: ${{ secrets.private_key }} 340 | app-id: ${{ secrets.app_id }} 341 | owner: ${{ github.repository_owner }} 342 | repositories: 'repo1,repo2' 343 | 344 | - name: Checkout 345 | uses: actions/checkout@v4.2.2 346 | 347 | - name: Self-hosted Renovate 348 | uses: renovatebot/github-action@v42.0.3 349 | with: 350 | configurationFile: example/renovate-config.js 351 | token: '${{ steps.get_token.outputs.token }}' 352 | ``` 353 | 354 | ### Commit signing with GitHub App 355 | 356 | Renovate can sign commits when deployed as a GitHub App by utilizing GitHub's API-based commits. 357 | To activate this, ensure that `platformCommit` is set to `true` in global config. 358 | If a configuration file is defined, include `platformCommit: true` to activate this feature. 359 | For example: 360 | 361 | ```yaml 362 | - name: Self-hosted Renovate 363 | uses: renovatebot/github-action@v42.0.3 364 | with: 365 | token: '${{ steps.get_token.outputs.token }}' 366 | env: 367 | RENOVATE_PLATFORM_COMMIT: 'true' 368 | ``` 369 | 370 | ## Environment Variables 371 | 372 | If you wish to pass through environment variables through to the Docker container that powers this action you need to prefix the environment variable with `RENOVATE_`. 373 | 374 | For example if you wish to pass through some credentials for a [host rule](https://docs.renovatebot.com/configuration-options/#hostrules) to the `config.js` then you should do so like this. 375 | 376 | 1. In your workflow pass in the environment variable 377 | 378 | ```yml 379 | .... 380 | jobs: 381 | renovate: 382 | runs-on: ubuntu-latest 383 | steps: 384 | - name: Checkout 385 | uses: actions/checkout@v4.2.2 386 | - name: Self-hosted Renovate 387 | uses: renovatebot/github-action@v42.0.3 388 | with: 389 | configurationFile: example/renovate-config.js 390 | token: ${{ secrets.RENOVATE_TOKEN }} 391 | env: 392 | RENOVATE_TFE_TOKEN: ${{ secrets.MY_TFE_TOKEN }} 393 | ``` 394 | 395 | 1. In `example/renovate-config.js` include the hostRules block 396 | 397 | ```js 398 | module.exports = { 399 | hostRules: [ 400 | { 401 | hostType: 'terraform-module', 402 | matchHost: 'app.terraform.io', 403 | token: process.env.RENOVATE_TFE_TOKEN, 404 | }, 405 | ], 406 | }; 407 | ``` 408 | 409 | ### Passing other environment variables 410 | 411 | If you want to pass other variables to the Docker container use the `env-regex` input to override the regular expression that is used to allow environment variables. 412 | 413 | In your workflow pass the environment variable and whitelist it by specifying the `env-regex`: 414 | 415 | ```yml 416 | .... 417 | jobs: 418 | renovate: 419 | runs-on: ubuntu-latest 420 | steps: 421 | - name: Checkout 422 | uses: actions/checkout@v4.2.2 423 | - name: Self-hosted Renovate 424 | uses: renovatebot/github-action@v42.0.3 425 | with: 426 | configurationFile: example/renovate-config.js 427 | token: ${{ secrets.RENOVATE_TOKEN }} 428 | env-regex: "^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|AWS_TOKEN)$" 429 | env: 430 | AWS_TOKEN: ${{ secrets.AWS_TOKEN }} 431 | ``` 432 | 433 | ## Persisting the repository cache 434 | 435 | In some cases, Renovate can update PRs more frequently than you expect. The [repository cache](https://docs.renovatebot.com/self-hosted-configuration/#repositorycache) can help with this issue. You need a few things to persist this cache in GitHub actions: 436 | 437 | 1. Enable the `repositoryCache` [option](https://docs.renovatebot.com/self-hosted-configuration/#repositorycache) via env vars or renovate.json. 438 | 2. Persist `/tmp/renovate/cache/renovate/repository` as an artifact. 439 | 3. Restore the artifact before renovate runs. 440 | 441 | Below is a workflow example with caching. 442 | 443 | Note that while archiving and compressing the cache is more performant, especially if you need to handle lots of files within the cache, it's not strictly necessary. You could simplify this workflow and only upload and download a single artifact file (or directory) with a direct path (e.g. `/tmp/renovate/cache/renovate/repository/github/$org/$repo.json`). However, you'll still need to set the correct permissions with `chown` as shown in the example. 444 | 445 | ```yml 446 | name: Renovate 447 | on: 448 | # This lets you dispatch a renovate job with different cache options if you want to reset or disable the cache manually. 449 | workflow_dispatch: 450 | inputs: 451 | repoCache: 452 | description: 'Reset or disable the cache?' 453 | type: choice 454 | default: enabled 455 | options: 456 | - enabled 457 | - disabled 458 | - reset 459 | schedule: 460 | # Run every 30 minutes: 461 | - cron: '0,30 * * * *' 462 | 463 | # Adding these as env variables makes it easy to re-use them in different steps and in bash. 464 | env: 465 | cache_archive: renovate_cache.tar.gz 466 | # This is the dir renovate provides -- if we set our own directory via cacheDir, we can run into permissions issues. 467 | # It is also possible to cache a higher level of the directory, but it has minimal benefit. While renovate execution 468 | # time gets faster, it also takes longer to upload the cache as it grows bigger. 469 | cache_dir: /tmp/renovate/cache/renovate/repository 470 | # This can be manually changed to bust the cache if neccessary. 471 | cache_key: renovate-cache 472 | 473 | jobs: 474 | renovate: 475 | name: Renovate 476 | runs-on: ubuntu-latest 477 | steps: 478 | - uses: actions/checkout@v3 479 | 480 | # This third party action allows you to download the cache artifact from different workflow runs 481 | # Note that actions/cache doesn't work well because the cache key would need to be computed from 482 | # a file within the cache, meaning there would never be any data to restore. With other keys, the 483 | # cache wouldn't necessarily upload when it changes. actions/download-artifact also doesn't work 484 | # because it only handles artifacts uploaded in the same run, and we want to restore from the 485 | # previous successful run. 486 | - uses: dawidd6/action-download-artifact@v2 487 | if: github.event.inputs.repoCache != 'disabled' 488 | continue-on-error: true 489 | with: 490 | name: ${{ env.cache_key }} 491 | path: cache-download 492 | 493 | # Using tar to compress and extract the archive isn't strictly necessary, but it can improve 494 | # performance significantly when uploading artifacts with lots of files. 495 | - name: Extract renovate cache 496 | run: | 497 | set -x 498 | # Skip if no cache is set, such as the first time it runs. 499 | if [ ! -d cache-download ] ; then 500 | echo "No cache found." 501 | exit 0 502 | fi 503 | 504 | # Make sure the directory exists, and extract it there. Note that it's nested in the download directory. 505 | mkdir -p $cache_dir 506 | tar -xzf cache-download/$cache_archive -C $cache_dir 507 | 508 | # Unfortunately, the permissions expected within renovate's docker container 509 | # are different than the ones given after the cache is restored. We have to 510 | # change ownership to solve this. We also need to have correct permissions in 511 | # the entire /tmp/renovate tree, not just the section with the repo cache. 512 | sudo chown -R 12021:0 /tmp/renovate/ 513 | ls -R $cache_dir 514 | 515 | - uses: renovatebot/github-action@v42.0.3 516 | with: 517 | configurationFile: renovate.json5 518 | token: ${{ secrets.RENOVATE_TOKEN }} 519 | renovate-version: 40.31.0 520 | env: 521 | # This enables the cache -- if this is set, it's not necessary to add it to renovate.json. 522 | RENOVATE_REPOSITORY_CACHE: ${{ github.event.inputs.repoCache || 'enabled' }} 523 | 524 | # Compression helps performance in the upload step! 525 | - name: Compress renovate cache 526 | run: | 527 | ls $cache_dir 528 | # The -C is important -- otherwise we end up extracting the files with 529 | # their full path, ultimately leading to a nested directory situation. 530 | # To solve *that*, we'd have to extract to root (/), which isn't safe. 531 | tar -czvf $cache_archive -C $cache_dir . 532 | 533 | - uses: actions/upload-artifact@v3 534 | if: github.event.inputs.repoCache != 'disabled' 535 | with: 536 | name: ${{ env.cache_key }} 537 | path: ${{ env.cache_archive }} 538 | # Since this is updated and restored on every run, we don't need to keep it 539 | # for long. Just make sure this value is large enough that multiple renovate 540 | # runs can happen before older cache archives are deleted. 541 | retention-days: 1 542 | ``` 543 | 544 | ## Troubleshooting 545 | 546 | ### Debug logging 547 | 548 | In case of issues, it's always a good idea to enable debug logging first. 549 | To enable debug logging, add the environment variable `LOG_LEVEL: 'debug'` to the action: 550 | 551 | ```yml 552 | - name: Self-hosted Renovate 553 | uses: renovatebot/github-action@v42.0.3 554 | with: 555 | configurationFile: example/renovate-config.js 556 | token: ${{ secrets.RENOVATE_TOKEN }} 557 | env: 558 | LOG_LEVEL: 'debug' 559 | ``` 560 | 561 | ### Special token requirements when using the `github-actions` manager 562 | 563 | 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. 564 | Otherwise, GitHub does not allow Renovate to update workflow files and therefore it will be unable to create update PRs for affected packages (like `actions/checkout` or `renovatebot/github-action` itself). 565 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Renovate Bot GitHub Action' 2 | description: 'GitHub Action to run self-hosted Renovate.' 3 | author: 'Jeroen de Bruijn' 4 | branding: 5 | icon: refresh-cw 6 | color: blue 7 | inputs: 8 | configurationFile: 9 | description: | 10 | Configuration file to configure Renovate. Either use this input or the 11 | 'RENOVATE_CONFIG_FILE' environment variable. 12 | required: false 13 | token: 14 | description: | 15 | GitHub personal access token that Renovate should use. This should be 16 | configured using a Secret. Either use this input or the 'RENOVATE_TOKEN' 17 | environment variable. 18 | required: false 19 | env-regex: 20 | description: | 21 | Override the environment variables which will be passsed into the renovate container. 22 | Defaults to `^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|(?:HTTPS?|NO)_PROXY|(?:https?|no)_proxy)$` 23 | required: false 24 | renovate-version: 25 | description: | 26 | Renovate version to use. 27 | required: false 28 | default: '40' # renovate 29 | renovate-image: 30 | description: | 31 | Renovate docker image name. 32 | required: false 33 | default: ghcr.io/renovatebot/renovate 34 | mount-docker-socket: 35 | description: | 36 | Mount the Docker socket inside the renovate container so that the commands 37 | can use Docker. Also add the user inside the renovate container to the 38 | docker group for socket permissions. 39 | required: false 40 | docker-socket-host-path: 41 | description: | 42 | Allows the overriding of the host path for the Docker socket that is mounted into the container. 43 | Useful on systems where the host Docker socket is located somewhere other than '/var/run/docker.sock' (the default). 44 | Only applicable when 'mount-docker-socket' is true. 45 | required: false 46 | default: /var/run/docker.sock 47 | docker-cmd-file: 48 | description: | 49 | Override docker command. Default command is `renovate` 50 | required: false 51 | docker-network: 52 | description: | 53 | Docker network. 54 | required: false 55 | docker-user: 56 | description: | 57 | Docker user. Default to an unprivileged user 58 | required: false 59 | docker-volumes: 60 | description: | 61 | Docker volume mounts. Default to /tmp:/tmp 62 | default: /tmp:/tmp 63 | required: false 64 | 65 | runs: 66 | using: node20 67 | main: dist/index.js 68 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extends: ['@commitlint/config-conventional'], 3 | }; 4 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-member-access */ 2 | /* eslint-disable @typescript-eslint/no-unsafe-argument */ 3 | import eslintConfigPrettier from 'eslint-config-prettier'; 4 | import globals from 'globals'; 5 | import js from '@eslint/js'; 6 | import json from 'eslint-plugin-json'; 7 | import tseslint from 'typescript-eslint'; 8 | 9 | export default tseslint.config( 10 | { 11 | ignores: [ 12 | '**/.git/', 13 | '**/.vscode', 14 | '**/build/', 15 | '**/dist/', 16 | '**/coverage/', 17 | '**/LICENSE.md', 18 | '**/modules/', 19 | '**/node_modules/', 20 | '!**/.*', 21 | ], 22 | }, 23 | js.configs.recommended, 24 | ...tseslint.configs.recommendedTypeChecked.map((config) => ({ 25 | ...config, 26 | files: ['**/*.{ts,js,mjs,cjs}'], 27 | })), 28 | ...tseslint.configs.stylisticTypeChecked.map((config) => ({ 29 | ...config, 30 | files: ['**/*.{ts,js,mjs,cjs}'], 31 | })), 32 | { 33 | files: ['**/*.{ts,js,mjs,cjs}'], 34 | 35 | linterOptions: { 36 | reportUnusedDisableDirectives: true, 37 | }, 38 | 39 | languageOptions: { 40 | globals: { 41 | ...globals.node, 42 | }, 43 | ecmaVersion: 'latest', 44 | sourceType: 'module', 45 | 46 | parserOptions: { 47 | projectService: true, 48 | tsconfigRootDir: import.meta.dirname, 49 | }, 50 | }, 51 | 52 | rules: { 53 | 'sort-imports': 'error', 54 | }, 55 | }, 56 | json.configs.recommended, 57 | { 58 | files: ['**/tsconfig.json', '**/tsconfig.*.json'], 59 | rules: { 60 | 'json/*': ['error', { allowComments: true }], 61 | }, 62 | }, 63 | eslintConfigPrettier, 64 | ); 65 | -------------------------------------------------------------------------------- /example/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | install-apt sl 6 | 7 | exec runuser -u ubuntu renovate 8 | -------------------------------------------------------------------------------- /example/renovate-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | branchPrefix: 'test-renovate/', 3 | username: 'renovate-release', 4 | gitAuthor: 'Renovate Bot ', 5 | onboarding: false, 6 | platform: 'github', 7 | forkProcessing: 'enabled', 8 | dryRun: 'full', 9 | repositories: ['renovate-tests/cocoapods1', 'renovate-tests/gomod1'], 10 | packageRules: [ 11 | { 12 | description: 'lockFileMaintenance', 13 | matchUpdateTypes: [ 14 | 'pin', 15 | 'digest', 16 | 'patch', 17 | 'minor', 18 | 'major', 19 | 'lockFileMaintenance', 20 | ], 21 | dependencyDashboardApproval: false, 22 | minimumReleaseAge: '0 days', 23 | }, 24 | ], 25 | }; 26 | -------------------------------------------------------------------------------- /example/renovate-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "branchPrefix": "test-renovate/", 3 | "dryRun": "full", 4 | "username": "renovate-release", 5 | "gitAuthor": "Renovate Bot ", 6 | "onboarding": false, 7 | "platform": "github", 8 | "forkProcessing": "enabled", 9 | "repositories": [ 10 | "renovatebot/github-action", 11 | "renovate-tests/cocoapods1", 12 | "renovate-tests/gomod1" 13 | ], 14 | "packageRules": [ 15 | { 16 | "description": "lockFileMaintenance", 17 | "matchUpdateTypes": [ 18 | "pin", 19 | "digest", 20 | "patch", 21 | "minor", 22 | "major", 23 | "lockFileMaintenance" 24 | ], 25 | "dependencyDashboardApproval": false, 26 | "minimumReleaseAge": 0 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | Renovate versions 12.0.0 (released 2018-04-09) and onwards are released 2 | under the GNU Affero General Public License. 3 | 4 | Renovate versions 11 and earlier were released under the MIT license 5 | and therefore the MIT notice is retained in this file for that code only. 6 | 7 | Both licenses are included below for reference: 8 | 9 | GNU AFFERO GENERAL PUBLIC LICENSE 10 | Version 3, 19 November 2007 11 | 12 | Copyright (C) 2007 Free Software Foundation, Inc. 13 | Everyone is permitted to copy and distribute verbatim copies 14 | of this license document, but changing it is not allowed. 15 | 16 | Preamble 17 | 18 | The GNU Affero General Public License is a free, copyleft license for 19 | software and other kinds of works, specifically designed to ensure 20 | cooperation with the community in the case of network server software. 21 | 22 | The licenses for most software and other practical works are designed 23 | to take away your freedom to share and change the works. By contrast, 24 | our General Public Licenses are intended to guarantee your freedom to 25 | share and change all versions of a program--to make sure it remains free 26 | software for all its users. 27 | 28 | When we speak of free software, we are referring to freedom, not 29 | price. Our General Public Licenses are designed to make sure that you 30 | have the freedom to distribute copies of free software (and charge for 31 | them if you wish), that you receive source code or can get it if you 32 | want it, that you can change the software or use pieces of it in new 33 | free programs, and that you know you can do these things. 34 | 35 | Developers that use our General Public Licenses protect your rights 36 | with two steps: (1) assert copyright on the software, and (2) offer 37 | you this License which gives you legal permission to copy, distribute 38 | and/or modify the software. 39 | 40 | A secondary benefit of defending all users' freedom is that 41 | improvements made in alternate versions of the program, if they 42 | receive widespread use, become available for other developers to 43 | incorporate. Many developers of free software are heartened and 44 | encouraged by the resulting cooperation. However, in the case of 45 | software used on network servers, this result may fail to come about. 46 | The GNU General Public License permits making a modified version and 47 | letting the public access it on a server without ever releasing its 48 | source code to the public. 49 | 50 | The GNU Affero General Public License is designed specifically to 51 | ensure that, in such cases, the modified source code becomes available 52 | to the community. It requires the operator of a network server to 53 | provide the source code of the modified version running there to the 54 | users of that server. Therefore, public use of a modified version, on 55 | a publicly accessible server, gives the public access to the source 56 | code of the modified version. 57 | 58 | An older license, called the Affero General Public License and 59 | published by Affero, was designed to accomplish similar goals. This is 60 | a different license, not a version of the Affero GPL, but Affero has 61 | released a new version of the Affero GPL which permits relicensing under 62 | this license. 63 | 64 | The precise terms and conditions for copying, distribution and 65 | modification follow. 66 | 67 | TERMS AND CONDITIONS 68 | 69 | 0. Definitions. 70 | 71 | "This License" refers to version 3 of the GNU Affero General Public License. 72 | 73 | "Copyright" also means copyright-like laws that apply to other kinds of 74 | works, such as semiconductor masks. 75 | 76 | "The Program" refers to any copyrightable work licensed under this 77 | License. Each licensee is addressed as "you". "Licensees" and 78 | "recipients" may be individuals or organizations. 79 | 80 | To "modify" a work means to copy from or adapt all or part of the work 81 | in a fashion requiring copyright permission, other than the making of an 82 | exact copy. The resulting work is called a "modified version" of the 83 | earlier work or a work "based on" the earlier work. 84 | 85 | A "covered work" means either the unmodified Program or a work based 86 | on the Program. 87 | 88 | To "propagate" a work means to do anything with it that, without 89 | permission, would make you directly or secondarily liable for 90 | infringement under applicable copyright law, except executing it on a 91 | computer or modifying a private copy. Propagation includes copying, 92 | distribution (with or without modification), making available to the 93 | public, and in some countries other activities as well. 94 | 95 | To "convey" a work means any kind of propagation that enables other 96 | parties to make or receive copies. Mere interaction with a user through 97 | a computer network, with no transfer of a copy, is not conveying. 98 | 99 | An interactive user interface displays "Appropriate Legal Notices" 100 | to the extent that it includes a convenient and prominently visible 101 | feature that (1) displays an appropriate copyright notice, and (2) 102 | tells the user that there is no warranty for the work (except to the 103 | extent that warranties are provided), that licensees may convey the 104 | work under this License, and how to view a copy of this License. If 105 | the interface presents a list of user commands or options, such as a 106 | menu, a prominent item in the list meets this criterion. 107 | 108 | 1. Source Code. 109 | 110 | The "source code" for a work means the preferred form of the work 111 | for making modifications to it. "Object code" means any non-source 112 | form of a work. 113 | 114 | A "Standard Interface" means an interface that either is an official 115 | standard defined by a recognized standards body, or, in the case of 116 | interfaces specified for a particular programming language, one that 117 | is widely used among developers working in that language. 118 | 119 | The "System Libraries" of an executable work include anything, other 120 | than the work as a whole, that (a) is included in the normal form of 121 | packaging a Major Component, but which is not part of that Major 122 | Component, and (b) serves only to enable use of the work with that 123 | Major Component, or to implement a Standard Interface for which an 124 | implementation is available to the public in source code form. A 125 | "Major Component", in this context, means a major essential component 126 | (kernel, window system, and so on) of the specific operating system 127 | (if any) on which the executable work runs, or a compiler used to 128 | produce the work, or an object code interpreter used to run it. 129 | 130 | The "Corresponding Source" for a work in object code form means all 131 | the source code needed to generate, install, and (for an executable 132 | work) run the object code and to modify the work, including scripts to 133 | control those activities. However, it does not include the work's 134 | System Libraries, or general-purpose tools or generally available free 135 | programs which are used unmodified in performing those activities but 136 | which are not part of the work. For example, Corresponding Source 137 | includes interface definition files associated with source files for 138 | the work, and the source code for shared libraries and dynamically 139 | linked subprograms that the work is specifically designed to require, 140 | such as by intimate data communication or control flow between those 141 | subprograms and other parts of the work. 142 | 143 | The Corresponding Source need not include anything that users 144 | can regenerate automatically from other parts of the Corresponding 145 | Source. 146 | 147 | The Corresponding Source for a work in source code form is that 148 | same work. 149 | 150 | 2. Basic Permissions. 151 | 152 | All rights granted under this License are granted for the term of 153 | copyright on the Program, and are irrevocable provided the stated 154 | conditions are met. This License explicitly affirms your unlimited 155 | permission to run the unmodified Program. The output from running a 156 | covered work is covered by this License only if the output, given its 157 | content, constitutes a covered work. This License acknowledges your 158 | rights of fair use or other equivalent, as provided by copyright law. 159 | 160 | You may make, run and propagate covered works that you do not 161 | convey, without conditions so long as your license otherwise remains 162 | in force. You may convey covered works to others for the sole purpose 163 | of having them make modifications exclusively for you, or provide you 164 | with facilities for running those works, provided that you comply with 165 | the terms of this License in conveying all material for which you do 166 | not control copyright. Those thus making or running the covered works 167 | for you must do so exclusively on your behalf, under your direction 168 | and control, on terms that prohibit them from making any copies of 169 | your copyrighted material outside their relationship with you. 170 | 171 | Conveying under any other circumstances is permitted solely under 172 | the conditions stated below. Sublicensing is not allowed; section 10 173 | makes it unnecessary. 174 | 175 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 176 | 177 | No covered work shall be deemed part of an effective technological 178 | measure under any applicable law fulfilling obligations under article 179 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 180 | similar laws prohibiting or restricting circumvention of such 181 | measures. 182 | 183 | When you convey a covered work, you waive any legal power to forbid 184 | circumvention of technological measures to the extent such circumvention 185 | is effected by exercising rights under this License with respect to 186 | the covered work, and you disclaim any intention to limit operation or 187 | modification of the work as a means of enforcing, against the work's 188 | users, your or third parties' legal rights to forbid circumvention of 189 | technological measures. 190 | 191 | 4. Conveying Verbatim Copies. 192 | 193 | You may convey verbatim copies of the Program's source code as you 194 | receive it, in any medium, provided that you conspicuously and 195 | appropriately publish on each copy an appropriate copyright notice; 196 | keep intact all notices stating that this License and any 197 | non-permissive terms added in accord with section 7 apply to the code; 198 | keep intact all notices of the absence of any warranty; and give all 199 | recipients a copy of this License along with the Program. 200 | 201 | You may charge any price or no price for each copy that you convey, 202 | and you may offer support or warranty protection for a fee. 203 | 204 | 5. Conveying Modified Source Versions. 205 | 206 | You may convey a work based on the Program, or the modifications to 207 | produce it from the Program, in the form of source code under the 208 | terms of section 4, provided that you also meet all of these conditions: 209 | 210 | a) The work must carry prominent notices stating that you modified 211 | it, and giving a relevant date. 212 | 213 | b) The work must carry prominent notices stating that it is 214 | released under this License and any conditions added under section 215 | 7. This requirement modifies the requirement in section 4 to 216 | "keep intact all notices". 217 | 218 | c) You must license the entire work, as a whole, under this 219 | License to anyone who comes into possession of a copy. This 220 | License will therefore apply, along with any applicable section 7 221 | additional terms, to the whole of the work, and all its parts, 222 | regardless of how they are packaged. This License gives no 223 | permission to license the work in any other way, but it does not 224 | invalidate such permission if you have separately received it. 225 | 226 | d) If the work has interactive user interfaces, each must display 227 | Appropriate Legal Notices; however, if the Program has interactive 228 | interfaces that do not display Appropriate Legal Notices, your 229 | work need not make them do so. 230 | 231 | A compilation of a covered work with other separate and independent 232 | works, which are not by their nature extensions of the covered work, 233 | and which are not combined with it such as to form a larger program, 234 | in or on a volume of a storage or distribution medium, is called an 235 | "aggregate" if the compilation and its resulting copyright are not 236 | used to limit the access or legal rights of the compilation's users 237 | beyond what the individual works permit. Inclusion of a covered work 238 | in an aggregate does not cause this License to apply to the other 239 | parts of the aggregate. 240 | 241 | 6. Conveying Non-Source Forms. 242 | 243 | You may convey a covered work in object code form under the terms 244 | of sections 4 and 5, provided that you also convey the 245 | machine-readable Corresponding Source under the terms of this License, 246 | in one of these ways: 247 | 248 | a) Convey the object code in, or embodied in, a physical product 249 | (including a physical distribution medium), accompanied by the 250 | Corresponding Source fixed on a durable physical medium 251 | customarily used for software interchange. 252 | 253 | b) Convey the object code in, or embodied in, a physical product 254 | (including a physical distribution medium), accompanied by a 255 | written offer, valid for at least three years and valid for as 256 | long as you offer spare parts or customer support for that product 257 | model, to give anyone who possesses the object code either (1) a 258 | copy of the Corresponding Source for all the software in the 259 | product that is covered by this License, on a durable physical 260 | medium customarily used for software interchange, for a price no 261 | more than your reasonable cost of physically performing this 262 | conveying of source, or (2) access to copy the 263 | Corresponding Source from a network server at no charge. 264 | 265 | c) Convey individual copies of the object code with a copy of the 266 | written offer to provide the Corresponding Source. This 267 | alternative is allowed only occasionally and noncommercially, and 268 | only if you received the object code with such an offer, in accord 269 | with subsection 6b. 270 | 271 | d) Convey the object code by offering access from a designated 272 | place (gratis or for a charge), and offer equivalent access to the 273 | Corresponding Source in the same way through the same place at no 274 | further charge. You need not require recipients to copy the 275 | Corresponding Source along with the object code. If the place to 276 | copy the object code is a network server, the Corresponding Source 277 | may be on a different server (operated by you or a third party) 278 | that supports equivalent copying facilities, provided you maintain 279 | clear directions next to the object code saying where to find the 280 | Corresponding Source. Regardless of what server hosts the 281 | Corresponding Source, you remain obligated to ensure that it is 282 | available for as long as needed to satisfy these requirements. 283 | 284 | e) Convey the object code using peer-to-peer transmission, provided 285 | you inform other peers where the object code and Corresponding 286 | Source of the work are being offered to the general public at no 287 | charge under subsection 6d. 288 | 289 | A separable portion of the object code, whose source code is excluded 290 | from the Corresponding Source as a System Library, need not be 291 | included in conveying the object code work. 292 | 293 | A "User Product" is either (1) a "consumer product", which means any 294 | tangible personal property which is normally used for personal, family, 295 | or household purposes, or (2) anything designed or sold for incorporation 296 | into a dwelling. In determining whether a product is a consumer product, 297 | doubtful cases shall be resolved in favor of coverage. For a particular 298 | product received by a particular user, "normally used" refers to a 299 | typical or common use of that class of product, regardless of the status 300 | of the particular user or of the way in which the particular user 301 | actually uses, or expects or is expected to use, the product. A product 302 | is a consumer product regardless of whether the product has substantial 303 | commercial, industrial or non-consumer uses, unless such uses represent 304 | the only significant mode of use of the product. 305 | 306 | "Installation Information" for a User Product means any methods, 307 | procedures, authorization keys, or other information required to install 308 | and execute modified versions of a covered work in that User Product from 309 | a modified version of its Corresponding Source. The information must 310 | suffice to ensure that the continued functioning of the modified object 311 | code is in no case prevented or interfered with solely because 312 | modification has been made. 313 | 314 | If you convey an object code work under this section in, or with, or 315 | specifically for use in, a User Product, and the conveying occurs as 316 | part of a transaction in which the right of possession and use of the 317 | User Product is transferred to the recipient in perpetuity or for a 318 | fixed term (regardless of how the transaction is characterized), the 319 | Corresponding Source conveyed under this section must be accompanied 320 | by the Installation Information. But this requirement does not apply 321 | if neither you nor any third party retains the ability to install 322 | modified object code on the User Product (for example, the work has 323 | been installed in ROM). 324 | 325 | The requirement to provide Installation Information does not include a 326 | requirement to continue to provide support service, warranty, or updates 327 | for a work that has been modified or installed by the recipient, or for 328 | the User Product in which it has been modified or installed. Access to a 329 | network may be denied when the modification itself materially and 330 | adversely affects the operation of the network or violates the rules and 331 | protocols for communication across the network. 332 | 333 | Corresponding Source conveyed, and Installation Information provided, 334 | in accord with this section must be in a format that is publicly 335 | documented (and with an implementation available to the public in 336 | source code form), and must require no special password or key for 337 | unpacking, reading or copying. 338 | 339 | 7. Additional Terms. 340 | 341 | "Additional permissions" are terms that supplement the terms of this 342 | License by making exceptions from one or more of its conditions. 343 | Additional permissions that are applicable to the entire Program shall 344 | be treated as though they were included in this License, to the extent 345 | that they are valid under applicable law. If additional permissions 346 | apply only to part of the Program, that part may be used separately 347 | under those permissions, but the entire Program remains governed by 348 | this License without regard to the additional permissions. 349 | 350 | When you convey a copy of a covered work, you may at your option 351 | remove any additional permissions from that copy, or from any part of 352 | it. (Additional permissions may be written to require their own 353 | removal in certain cases when you modify the work.) You may place 354 | additional permissions on material, added by you to a covered work, 355 | for which you have or can give appropriate copyright permission. 356 | 357 | Notwithstanding any other provision of this License, for material you 358 | add to a covered work, you may (if authorized by the copyright holders of 359 | that material) supplement the terms of this License with terms: 360 | 361 | a) Disclaiming warranty or limiting liability differently from the 362 | terms of sections 15 and 16 of this License; or 363 | 364 | b) Requiring preservation of specified reasonable legal notices or 365 | author attributions in that material or in the Appropriate Legal 366 | Notices displayed by works containing it; or 367 | 368 | c) Prohibiting misrepresentation of the origin of that material, or 369 | requiring that modified versions of such material be marked in 370 | reasonable ways as different from the original version; or 371 | 372 | d) Limiting the use for publicity purposes of names of licensors or 373 | authors of the material; or 374 | 375 | e) Declining to grant rights under trademark law for use of some 376 | trade names, trademarks, or service marks; or 377 | 378 | f) Requiring indemnification of licensors and authors of that 379 | material by anyone who conveys the material (or modified versions of 380 | it) with contractual assumptions of liability to the recipient, for 381 | any liability that these contractual assumptions directly impose on 382 | those licensors and authors. 383 | 384 | All other non-permissive additional terms are considered "further 385 | restrictions" within the meaning of section 10. If the Program as you 386 | received it, or any part of it, contains a notice stating that it is 387 | governed by this License along with a term that is a further 388 | restriction, you may remove that term. If a license document contains 389 | a further restriction but permits relicensing or conveying under this 390 | License, you may add to a covered work material governed by the terms 391 | of that license document, provided that the further restriction does 392 | not survive such relicensing or conveying. 393 | 394 | If you add terms to a covered work in accord with this section, you 395 | must place, in the relevant source files, a statement of the 396 | additional terms that apply to those files, or a notice indicating 397 | where to find the applicable terms. 398 | 399 | Additional terms, permissive or non-permissive, may be stated in the 400 | form of a separately written license, or stated as exceptions; 401 | the above requirements apply either way. 402 | 403 | 8. Termination. 404 | 405 | You may not propagate or modify a covered work except as expressly 406 | provided under this License. Any attempt otherwise to propagate or 407 | modify it is void, and will automatically terminate your rights under 408 | this License (including any patent licenses granted under the third 409 | paragraph of section 11). 410 | 411 | However, if you cease all violation of this License, then your 412 | license from a particular copyright holder is reinstated (a) 413 | provisionally, unless and until the copyright holder explicitly and 414 | finally terminates your license, and (b) permanently, if the copyright 415 | holder fails to notify you of the violation by some reasonable means 416 | prior to 60 days after the cessation. 417 | 418 | Moreover, your license from a particular copyright holder is 419 | reinstated permanently if the copyright holder notifies you of the 420 | violation by some reasonable means, this is the first time you have 421 | received notice of violation of this License (for any work) from that 422 | copyright holder, and you cure the violation prior to 30 days after 423 | your receipt of the notice. 424 | 425 | Termination of your rights under this section does not terminate the 426 | licenses of parties who have received copies or rights from you under 427 | this License. If your rights have been terminated and not permanently 428 | reinstated, you do not qualify to receive new licenses for the same 429 | material under section 10. 430 | 431 | 9. Acceptance Not Required for Having Copies. 432 | 433 | You are not required to accept this License in order to receive or 434 | run a copy of the Program. Ancillary propagation of a covered work 435 | occurring solely as a consequence of using peer-to-peer transmission 436 | to receive a copy likewise does not require acceptance. However, 437 | nothing other than this License grants you permission to propagate or 438 | modify any covered work. These actions infringe copyright if you do 439 | not accept this License. Therefore, by modifying or propagating a 440 | covered work, you indicate your acceptance of this License to do so. 441 | 442 | 10. Automatic Licensing of Downstream Recipients. 443 | 444 | Each time you convey a covered work, the recipient automatically 445 | receives a license from the original licensors, to run, modify and 446 | propagate that work, subject to this License. You are not responsible 447 | for enforcing compliance by third parties with this License. 448 | 449 | An "entity transaction" is a transaction transferring control of an 450 | organization, or substantially all assets of one, or subdividing an 451 | organization, or merging organizations. If propagation of a covered 452 | work results from an entity transaction, each party to that 453 | transaction who receives a copy of the work also receives whatever 454 | licenses to the work the party's predecessor in interest had or could 455 | give under the previous paragraph, plus a right to possession of the 456 | Corresponding Source of the work from the predecessor in interest, if 457 | the predecessor has it or can get it with reasonable efforts. 458 | 459 | You may not impose any further restrictions on the exercise of the 460 | rights granted or affirmed under this License. For example, you may 461 | not impose a license fee, royalty, or other charge for exercise of 462 | rights granted under this License, and you may not initiate litigation 463 | (including a cross-claim or counterclaim in a lawsuit) alleging that 464 | any patent claim is infringed by making, using, selling, offering for 465 | sale, or importing the Program or any portion of it. 466 | 467 | 11. Patents. 468 | 469 | A "contributor" is a copyright holder who authorizes use under this 470 | License of the Program or a work on which the Program is based. The 471 | work thus licensed is called the contributor's "contributor version". 472 | 473 | A contributor's "essential patent claims" are all patent claims 474 | owned or controlled by the contributor, whether already acquired or 475 | hereafter acquired, that would be infringed by some manner, permitted 476 | by this License, of making, using, or selling its contributor version, 477 | but do not include claims that would be infringed only as a 478 | consequence of further modification of the contributor version. For 479 | purposes of this definition, "control" includes the right to grant 480 | patent sublicenses in a manner consistent with the requirements of 481 | this License. 482 | 483 | Each contributor grants you a non-exclusive, worldwide, royalty-free 484 | patent license under the contributor's essential patent claims, to 485 | make, use, sell, offer for sale, import and otherwise run, modify and 486 | propagate the contents of its contributor version. 487 | 488 | In the following three paragraphs, a "patent license" is any express 489 | agreement or commitment, however denominated, not to enforce a patent 490 | (such as an express permission to practice a patent or covenant not to 491 | sue for patent infringement). To "grant" such a patent license to a 492 | party means to make such an agreement or commitment not to enforce a 493 | patent against the party. 494 | 495 | If you convey a covered work, knowingly relying on a patent license, 496 | and the Corresponding Source of the work is not available for anyone 497 | to copy, free of charge and under the terms of this License, through a 498 | publicly available network server or other readily accessible means, 499 | then you must either (1) cause the Corresponding Source to be so 500 | available, or (2) arrange to deprive yourself of the benefit of the 501 | patent license for this particular work, or (3) arrange, in a manner 502 | consistent with the requirements of this License, to extend the patent 503 | license to downstream recipients. "Knowingly relying" means you have 504 | actual knowledge that, but for the patent license, your conveying the 505 | covered work in a country, or your recipient's use of the covered work 506 | in a country, would infringe one or more identifiable patents in that 507 | country that you have reason to believe are valid. 508 | 509 | If, pursuant to or in connection with a single transaction or 510 | arrangement, you convey, or propagate by procuring conveyance of, a 511 | covered work, and grant a patent license to some of the parties 512 | receiving the covered work authorizing them to use, propagate, modify 513 | or convey a specific copy of the covered work, then the patent license 514 | you grant is automatically extended to all recipients of the covered 515 | work and works based on it. 516 | 517 | A patent license is "discriminatory" if it does not include within 518 | the scope of its coverage, prohibits the exercise of, or is 519 | conditioned on the non-exercise of one or more of the rights that are 520 | specifically granted under this License. You may not convey a covered 521 | work if you are a party to an arrangement with a third party that is 522 | in the business of distributing software, under which you make payment 523 | to the third party based on the extent of your activity of conveying 524 | the work, and under which the third party grants, to any of the 525 | parties who would receive the covered work from you, a discriminatory 526 | patent license (a) in connection with copies of the covered work 527 | conveyed by you (or copies made from those copies), or (b) primarily 528 | for and in connection with specific products or compilations that 529 | contain the covered work, unless you entered into that arrangement, 530 | or that patent license was granted, prior to 28 March 2007. 531 | 532 | Nothing in this License shall be construed as excluding or limiting 533 | any implied license or other defenses to infringement that may 534 | otherwise be available to you under applicable patent law. 535 | 536 | 12. No Surrender of Others' Freedom. 537 | 538 | If conditions are imposed on you (whether by court order, agreement or 539 | otherwise) that contradict the conditions of this License, they do not 540 | excuse you from the conditions of this License. If you cannot convey a 541 | covered work so as to satisfy simultaneously your obligations under this 542 | License and any other pertinent obligations, then as a consequence you may 543 | not convey it at all. For example, if you agree to terms that obligate you 544 | to collect a royalty for further conveying from those to whom you convey 545 | the Program, the only way you could satisfy both those terms and this 546 | License would be to refrain entirely from conveying the Program. 547 | 548 | 13. Remote Network Interaction; Use with the GNU General Public License. 549 | 550 | Notwithstanding any other provision of this License, if you modify the 551 | Program, your modified version must prominently offer all users 552 | interacting with it remotely through a computer network (if your version 553 | supports such interaction) an opportunity to receive the Corresponding 554 | Source of your version by providing access to the Corresponding Source 555 | from a network server at no charge, through some standard or customary 556 | means of facilitating copying of software. This Corresponding Source 557 | shall include the Corresponding Source for any work covered by version 3 558 | of the GNU General Public License that is incorporated pursuant to the 559 | following paragraph. 560 | 561 | Notwithstanding any other provision of this License, you have 562 | permission to link or combine any covered work with a work licensed 563 | under version 3 of the GNU General Public License into a single 564 | combined work, and to convey the resulting work. The terms of this 565 | License will continue to apply to the part which is the covered work, 566 | but the work with which it is combined will remain governed by version 567 | 3 of the GNU General Public License. 568 | 569 | 14. Revised Versions of this License. 570 | 571 | The Free Software Foundation may publish revised and/or new versions of 572 | the GNU Affero General Public License from time to time. Such new versions 573 | will be similar in spirit to the present version, but may differ in detail to 574 | address new problems or concerns. 575 | 576 | Each version is given a distinguishing version number. If the 577 | Program specifies that a certain numbered version of the GNU Affero General 578 | Public License "or any later version" applies to it, you have the 579 | option of following the terms and conditions either of that numbered 580 | version or of any later version published by the Free Software 581 | Foundation. If the Program does not specify a version number of the 582 | GNU Affero General Public License, you may choose any version ever published 583 | by the Free Software Foundation. 584 | 585 | If the Program specifies that a proxy can decide which future 586 | versions of the GNU Affero General Public License can be used, that proxy's 587 | public statement of acceptance of a version permanently authorizes you 588 | to choose that version for the Program. 589 | 590 | Later license versions may give you additional or different 591 | permissions. However, no additional obligations are imposed on any 592 | author or copyright holder as a result of your choosing to follow a 593 | later version. 594 | 595 | 15. Disclaimer of Warranty. 596 | 597 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 598 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 599 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 600 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 601 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 602 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 603 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 604 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 605 | 606 | 16. Limitation of Liability. 607 | 608 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 609 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 610 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 611 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 612 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 613 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 614 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 615 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 616 | SUCH DAMAGES. 617 | 618 | 17. Interpretation of Sections 15 and 16. 619 | 620 | If the disclaimer of warranty and limitation of liability provided 621 | above cannot be given local legal effect according to their terms, 622 | reviewing courts shall apply local law that most closely approximates 623 | an absolute waiver of all civil liability in connection with the 624 | Program, unless a warranty or assumption of liability accompanies a 625 | copy of the Program in return for a fee. 626 | 627 | END OF TERMS AND CONDITIONS 628 | 629 | How to Apply These Terms to Your New Programs 630 | 631 | If you develop a new program, and you want it to be of the greatest 632 | possible use to the public, the best way to achieve this is to make it 633 | free software which everyone can redistribute and change under these terms. 634 | 635 | To do so, attach the following notices to the program. It is safest 636 | to attach them to the start of each source file to most effectively 637 | state the exclusion of warranty; and each file should have at least 638 | the "copyright" line and a pointer to where the full notice is found. 639 | 640 | 641 | Copyright (C) 642 | 643 | This program is free software: you can redistribute it and/or modify 644 | it under the terms of the GNU Affero General Public License as published by 645 | the Free Software Foundation, either version 3 of the License, or 646 | (at your option) any later version. 647 | 648 | This program is distributed in the hope that it will be useful, 649 | but WITHOUT ANY WARRANTY; without even the implied warranty of 650 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 651 | GNU Affero General Public License for more details. 652 | 653 | You should have received a copy of the GNU Affero General Public License 654 | along with this program. If not, see . 655 | 656 | Also add information on how to contact you by electronic and paper mail. 657 | 658 | If your software can interact with users remotely through a computer 659 | network, you should also make sure that it provides a way for users to 660 | get its source. For example, if your program is a web application, its 661 | interface could display a "Source" link that leads users to an archive 662 | of the code. There are many ways you could offer source, and different 663 | solutions will be better for different programs; see section 13 for the 664 | specific requirements. 665 | 666 | You should also get your employer (if you work as a programmer) or school, 667 | if any, to sign a "copyright disclaimer" for the program, if necessary. 668 | For more information on this, and how to apply and follow the GNU AGPL, see 669 | . 670 | 671 | MIT -- for code released prior to v12.0.0 672 | --- 673 | 674 | Copyright (c) 2017 Rhys Arkins (rhys.arkins.net) 675 | 676 | Permission is hereby granted, free of charge, to any person obtaining a copy 677 | of this software and associated documentation files (the "Software"), to deal 678 | in the Software without restriction, including without limitation the rights 679 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 680 | copies of the Software, and to permit persons to whom the Software is 681 | furnished to do so, subject to the following conditions: 682 | 683 | The above copyright notice and this permission notice shall be included in all 684 | copies or substantial portions of the Software. 685 | 686 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 687 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 688 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 689 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 690 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 691 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 692 | SOFTWARE. 693 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-action", 3 | "version": "0.0.0-PLACEHOLDER", 4 | "private": true, 5 | "description": "GitHub Action to run Renovate self-hosted.", 6 | "homepage": "https://github.com/renovatebot/github-action#readme", 7 | "bugs": { 8 | "url": "https://github.com/renovatebot/github-action/issues" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/renovatebot/github-action.git" 13 | }, 14 | "license": "GPL-3.0-or-later", 15 | "author": "Jeroen de Bruijn", 16 | "type": "module", 17 | "main": "src/index.ts", 18 | "scripts": { 19 | "build": "run-s clean compile", 20 | "clean": "rimraf dist/", 21 | "compile": "node tools/compile.js", 22 | "lint": "run-s lint-es prettier", 23 | "lint:fix": "run-s lint-es:fix prettier-fix", 24 | "lint-es": "eslint .", 25 | "lint-es:file": "eslint", 26 | "lint-es:file:fix": "eslint --fix", 27 | "lint-es:fix": "eslint --fix .", 28 | "prepare": "husky", 29 | "prettier": "prettier --cache --check --ignore-unknown \"{**/*,*}.*\"", 30 | "prettier-fix": "prettier --cache --write --ignore-unknown \"{**/*,*}.*\"", 31 | "release": "run-s clean build semantic-release", 32 | "semantic-release": "semantic-release", 33 | "start": "run-s build && node dist" 34 | }, 35 | "dependencies": { 36 | "@actions/core": "1.11.1", 37 | "@actions/exec": "1.1.1" 38 | }, 39 | "devDependencies": { 40 | "@commitlint/cli": "19.8.1", 41 | "@commitlint/config-conventional": "19.8.1", 42 | "@eslint/js": "9.27.0", 43 | "@semantic-release/git": "10.0.1", 44 | "@semantic-release/github": "11.0.2", 45 | "@semantic-release/npm": "12.0.1", 46 | "@tsconfig/node20": "20.1.5", 47 | "@tsconfig/strictest": "2.0.5", 48 | "@types/eslint-config-prettier": "6.11.3", 49 | "@types/node": "20.17.50", 50 | "conventional-changelog-conventionalcommits": "8.0.0", 51 | "esbuild": "0.25.4", 52 | "eslint": "9.27.0", 53 | "eslint-config-prettier": "10.1.5", 54 | "eslint-plugin-json": "4.0.1", 55 | "globals": "16.1.0", 56 | "husky": "9.1.7", 57 | "lint-staged": "15.5.2", 58 | "npm-run-all2": "7.0.2", 59 | "prettier": "3.5.3", 60 | "prettier-plugin-packagejson": "2.5.10", 61 | "rimraf": "6.0.1", 62 | "semantic-release": "24.2.5", 63 | "typescript": "5.8.3", 64 | "typescript-eslint": "8.32.1" 65 | }, 66 | "packageManager": "pnpm@10.11.0", 67 | "engines": { 68 | "node": "^20.9.0 || ^22.11.0", 69 | "pnpm": "^10.0.0" 70 | }, 71 | "pnpm": { 72 | "supportedArchitectures": { 73 | "cpu": [ 74 | "x64" 75 | ], 76 | "os": [ 77 | "linux", 78 | "win32" 79 | ] 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/docker.ts: -------------------------------------------------------------------------------- 1 | import type { Input } from './input'; 2 | import { warning } from '@actions/core'; 3 | 4 | export class Docker { 5 | private static readonly image = 'ghcr.io/renovatebot/renovate'; 6 | private static readonly version = '40'; // renovate 7 | 8 | private readonly dockerImage: string; 9 | private readonly fullTag: string; 10 | 11 | constructor(input: Input) { 12 | let image = input.getDockerImage(); 13 | let version = input.getVersion(); 14 | 15 | if (!image) { 16 | warning(`No Docker image specified, using ${Docker.image}`); 17 | image = Docker.image; 18 | } 19 | if (!version) { 20 | warning(`No Docker version specified, using ${Docker.version}`); 21 | version = Docker.version; 22 | } 23 | 24 | this.dockerImage = image; 25 | this.fullTag = version; 26 | } 27 | 28 | image(): string { 29 | return `${this.dockerImage}:${this.fullTag}`; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { Input } from './input'; 2 | import { Renovate } from './renovate'; 3 | import { setFailed } from '@actions/core'; 4 | 5 | async function run(): Promise { 6 | try { 7 | const input = new Input(); 8 | const renovate = new Renovate(input); 9 | 10 | await renovate.runDockerContainer(); 11 | } catch (error) { 12 | console.error(error); 13 | setFailed(error as Error); 14 | } 15 | } 16 | 17 | void run(); 18 | -------------------------------------------------------------------------------- /src/input.ts: -------------------------------------------------------------------------------- 1 | import { getInput } from '@actions/core'; 2 | import path from 'node:path'; 3 | 4 | export interface EnvironmentVariable { 5 | key: string; 6 | value: string; 7 | } 8 | 9 | export class Input { 10 | readonly options = { 11 | envRegex: 12 | /^(?:RENOVATE_\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|(?:HTTPS?|NO)_PROXY|(?:https?|no)_proxy)$/, 13 | configurationFile: { 14 | input: 'configurationFile', 15 | env: 'RENOVATE_CONFIG_FILE', 16 | optional: true, 17 | }, 18 | token: { 19 | input: 'token', 20 | env: 'RENOVATE_TOKEN', 21 | optional: false, 22 | }, 23 | } as const; 24 | readonly token: Readonly; 25 | 26 | private readonly _environmentVariables: Map; 27 | private readonly _configurationFile: Readonly; 28 | 29 | constructor() { 30 | const envRegexInput = getInput('env-regex'); 31 | const envRegex = envRegexInput 32 | ? new RegExp(envRegexInput) 33 | : this.options.envRegex; 34 | this._environmentVariables = new Map( 35 | Object.entries(process.env) 36 | .filter(([key]) => envRegex.test(key)) 37 | .filter((pair): pair is [string, string] => pair[1] !== undefined), 38 | ); 39 | 40 | this.token = this.get( 41 | this.options.token.input, 42 | this.options.token.env, 43 | this.options.token.optional, 44 | ); 45 | this._configurationFile = this.get( 46 | this.options.configurationFile.input, 47 | this.options.configurationFile.env, 48 | this.options.configurationFile.optional, 49 | ); 50 | } 51 | 52 | configurationFile(): EnvironmentVariable | null { 53 | if (this._configurationFile.value !== '') { 54 | return { 55 | key: this._configurationFile.key, 56 | value: path.resolve(this._configurationFile.value), 57 | }; 58 | } 59 | 60 | return null; 61 | } 62 | 63 | getDockerImage(): string | null { 64 | return getInput('renovate-image') || null; 65 | } 66 | 67 | getVersion(): string | null { 68 | return getInput('renovate-version') || null; 69 | } 70 | 71 | mountDockerSocket(): boolean { 72 | return getInput('mount-docker-socket') === 'true'; 73 | } 74 | 75 | dockerSocketHostPath(): string { 76 | return getInput('docker-socket-host-path') || '/var/run/docker.sock'; 77 | } 78 | 79 | getDockerCmdFile(): string | null { 80 | const cmdFile = getInput('docker-cmd-file'); 81 | return !!cmdFile && cmdFile !== '' ? path.resolve(cmdFile) : null; 82 | } 83 | 84 | getDockerUser(): string | null { 85 | return getInput('docker-user') || null; 86 | } 87 | 88 | getDockerVolumeMounts(): string[] { 89 | return getInput('docker-volumes') 90 | .split(';') 91 | .map((v) => v.trim()) 92 | .filter((v) => !!v); 93 | } 94 | 95 | getDockerNetwork(): string { 96 | return getInput('docker-network'); 97 | } 98 | 99 | /** 100 | * Convert to environment variables. 101 | * 102 | * @note The environment variables listed below are filtered out. 103 | * - Token, available with the `token` property. 104 | * - Configuration file, available with the `configurationFile()` method. 105 | */ 106 | toEnvironmentVariables(): EnvironmentVariable[] { 107 | return [...this._environmentVariables].map(([key, value]) => ({ 108 | key, 109 | value, 110 | })); 111 | } 112 | 113 | private get( 114 | input: string, 115 | env: string, 116 | optional: boolean, 117 | ): EnvironmentVariable { 118 | const fromInput = getInput(input); 119 | const fromEnv = this._environmentVariables.get(env); 120 | 121 | if (fromInput === '' && fromEnv === undefined && !optional) { 122 | throw new Error( 123 | [ 124 | `'${input}' MUST be passed using its input or the '${env}'`, 125 | 'environment variable', 126 | ].join(' '), 127 | ); 128 | } 129 | 130 | this._environmentVariables.delete(env); 131 | if (fromInput !== '') { 132 | return { key: env, value: fromInput }; 133 | } 134 | return { key: env, value: fromEnv ?? '' }; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/renovate.ts: -------------------------------------------------------------------------------- 1 | import { Docker } from './docker'; 2 | import { Input } from './input'; 3 | import { exec } from '@actions/exec'; 4 | import fs from 'node:fs/promises'; 5 | import path from 'node:path'; 6 | 7 | export class Renovate { 8 | static dockerGroupRegex = /^docker:x:(?[1-9][0-9]*):/m; 9 | private configFileMountDir = '/github-action'; 10 | 11 | private docker: Docker; 12 | 13 | constructor(private input: Input) { 14 | this.docker = new Docker(input); 15 | } 16 | 17 | async runDockerContainer(): Promise { 18 | await this.validateArguments(); 19 | 20 | const dockerArguments = this.input 21 | .toEnvironmentVariables() 22 | .map((e) => `--env ${e.key}`) 23 | .concat([`--env ${this.input.token.key}=${this.input.token.value}`]); 24 | 25 | const configurationFile = this.input.configurationFile(); 26 | if (configurationFile !== null) { 27 | const baseName = path.basename(configurationFile.value); 28 | const mountPath = path.join(this.configFileMountDir, baseName); 29 | dockerArguments.push( 30 | `--env ${configurationFile.key}=${mountPath}`, 31 | `--volume ${configurationFile.value}:${mountPath}`, 32 | ); 33 | } 34 | 35 | if (this.input.mountDockerSocket()) { 36 | const sockPath = this.input.dockerSocketHostPath(); 37 | const stat = await fs.stat(sockPath); 38 | if (!stat.isSocket()) { 39 | throw new Error( 40 | `docker socket host path '${sockPath}' MUST exist and be a socket`, 41 | ); 42 | } 43 | 44 | dockerArguments.push( 45 | `--volume ${sockPath}:/var/run/docker.sock`, 46 | `--group-add ${await this.getDockerGroupId()}`, 47 | ); 48 | } 49 | 50 | const dockerCmdFile = this.input.getDockerCmdFile(); 51 | let dockerCmd: string | null = null; 52 | if (dockerCmdFile !== null) { 53 | const baseName = path.basename(dockerCmdFile); 54 | const mountPath = `/${baseName}`; 55 | dockerArguments.push(`--volume ${dockerCmdFile}:${mountPath}`); 56 | dockerCmd = mountPath; 57 | } 58 | 59 | const dockerUser = this.input.getDockerUser(); 60 | if (dockerUser !== null) { 61 | dockerArguments.push(`--user ${dockerUser}`); 62 | } 63 | 64 | for (const volumeMount of this.input.getDockerVolumeMounts()) { 65 | dockerArguments.push(`--volume ${volumeMount}`); 66 | } 67 | 68 | const dockerNetwork = this.input.getDockerNetwork(); 69 | if (dockerNetwork) { 70 | dockerArguments.push(`--network ${dockerNetwork}`); 71 | } 72 | 73 | dockerArguments.push('--rm', this.docker.image()); 74 | 75 | if (dockerCmd !== null) { 76 | dockerArguments.push(dockerCmd); 77 | } 78 | 79 | const command = `docker run ${dockerArguments.join(' ')}`; 80 | 81 | const code = await exec(command); 82 | if (code !== 0) { 83 | new Error(`'docker run' failed with exit code ${code}.`); 84 | } 85 | } 86 | 87 | /** 88 | * Fetch the host docker group of the GitHub Action runner. 89 | * 90 | * The Renovate container needs access to this group in order to have the 91 | * required permissions on the Docker socket. 92 | */ 93 | private async getDockerGroupId(): Promise { 94 | const groupFile = '/etc/group'; 95 | const groups = await fs.readFile(groupFile, { 96 | encoding: 'utf-8', 97 | }); 98 | 99 | /** 100 | * The group file has `groupname:group-password:GID:username-list` as 101 | * structure and we're interested in the `GID` (the group ID). 102 | * 103 | * Source: https://www.thegeekdiary.com/etcgroup-file-explained/ 104 | */ 105 | const match = Renovate.dockerGroupRegex.exec(groups); 106 | if (match?.groups?.groupId === undefined) { 107 | throw new Error(`Could not find group docker in ${groupFile}`); 108 | } 109 | 110 | return match.groups.groupId; 111 | } 112 | 113 | private async validateArguments(): Promise { 114 | if (/\s/.test(this.input.token.value)) { 115 | throw new Error('Token MUST NOT contain whitespace'); 116 | } 117 | 118 | const configurationFile = this.input.configurationFile(); 119 | if ( 120 | configurationFile !== null && 121 | !(await fs.stat(configurationFile.value)).isFile() 122 | ) { 123 | throw new Error( 124 | `configuration file '${configurationFile.value}' MUST be an existing file`, 125 | ); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /tools/cjs-shim.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/evanw/esbuild/issues/1921#issuecomment-1898197331 2 | import { createRequire } from 'node:module'; 3 | import path from 'node:path'; 4 | import url from 'node:url'; 5 | 6 | globalThis.require = createRequire(import.meta.url); 7 | globalThis.__filename = url.fileURLToPath(import.meta.url); 8 | globalThis.__dirname = path.dirname(__filename); 9 | -------------------------------------------------------------------------------- /tools/compile.js: -------------------------------------------------------------------------------- 1 | import { build } from 'esbuild'; 2 | import { env } from 'node:process'; 3 | 4 | await build({ 5 | entryPoints: ['./src/index.ts'], 6 | bundle: true, 7 | platform: 'node', 8 | target: 'node20', 9 | minify: !!env['CI'], 10 | tsconfig: 'tsconfig.dist.json', 11 | sourcemap: true, 12 | format: 'esm', 13 | outdir: './dist/', 14 | inject: ['tools/cjs-shim.ts'], // https://github.com/evanw/esbuild/issues/1921#issuecomment-1898197331 15 | }); 16 | -------------------------------------------------------------------------------- /tools/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@tsconfig/strictest/tsconfig.json", 4 | "@tsconfig/node20/tsconfig.json" 5 | ], 6 | "compilerOptions": { 7 | "allowSyntheticDefaultImports": true, 8 | "esModuleInterop": true, 9 | "noEmit": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.dist.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "types": ["node"] 5 | }, 6 | "files": ["./src/index.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@tsconfig/strictest/tsconfig.json", 4 | "@tsconfig/node20/tsconfig.json" 5 | ], 6 | "compilerOptions": { 7 | "allowSyntheticDefaultImports": true, 8 | "outDir": "dist", 9 | "module": "ESNext", 10 | "moduleResolution": "Bundler", 11 | "noImplicitAny": false, 12 | "noPropertyAccessFromIndexSignature": false /* makes code more complex */ 13 | }, 14 | "exclude": ["node_modules/", "**/__mocks__/*", "dist/", "coverage/", "html/"] 15 | } 16 | --------------------------------------------------------------------------------