|
| 1 | +--- |
| 2 | +name: Renovate |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 0 * * 0' # every Sunday at midnight UTC |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + dry_run: |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + description: If true, the Renovate will not make any changes |
| 16 | + required: false |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + packages: read # Manage private ghcr.io dependencies |
| 21 | + |
| 22 | +env: |
| 23 | + LOG_LEVEL: debug |
| 24 | + # renovate: datasource=docker depName=renovate packageName=ghcr.io/renovatebot/renovate |
| 25 | + RENOVATE_VERSION: 41.91.0 |
| 26 | + |
| 27 | +# https://docs.github.com/en/actions/using-jobs/using-concurrency |
| 28 | +# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 31 | + # Expressions in the concurrency context do not have access |
| 32 | + # to the entire github.event context so we cannot make advanced |
| 33 | + # expressions beyond a few top level github event properties. |
| 34 | + |
| 35 | + # See: https://github.com/orgs/community/discussions/69704#discussioncomment-7803351 |
| 36 | + |
| 37 | + # Cancel jobs in-progress for dry-runs or open PRs |
| 38 | + cancel-in-progress: ${{ inputs.dry_run || github.event_name == 'pull_request' }} |
| 39 | + |
| 40 | +jobs: |
| 41 | + renovate: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + |
| 44 | + env: |
| 45 | + # See https://github.com/marketplace/actions/renovate-bot-github-action#persisting-the-repository-cache |
| 46 | + RENOVATE_REPOSITORY_CACHE: 'enabled' |
| 47 | + RENOVATE_CACHE_PRIVATE_PACKAGES: "true" |
| 48 | + # This is the dir renovate provides -- if we set our own directory via cacheDir, we can run into permissions issues. |
| 49 | + # It is also possible to cache a higher level of the directory, but it has minimal benefit. While renovate execution |
| 50 | + # time gets faster, it also takes longer to upload the cache as it grows bigger. |
| 51 | + cache_dir: /tmp/renovate/cache/renovate/repository |
| 52 | + cache_key: renovate-cache-${{ github.repository_owner }}-${{ github.run_id }} |
| 53 | + restore_key: renovate-cache-${{ github.repository_owner }} |
| 54 | + |
| 55 | + steps: |
| 56 | + # https://github.com/actions/checkout |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 59 | + with: |
| 60 | + persist-credentials: false |
| 61 | + |
| 62 | + # https://github.com/actions/create-github-app-token |
| 63 | + - name: Generate GitHub App installation token |
| 64 | + uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1 |
| 65 | + id: app_token |
| 66 | + with: |
| 67 | + app-id: ${{ vars.RENOVATE_APP_ID || '290907' }} |
| 68 | + private-key: ${{ secrets.RENOVATE_APP_PRIVATE_KEY || secrets.GH_APP_PRIVATE_KEY }} |
| 69 | + owner: ${{ github.repository_owner }} |
| 70 | + |
| 71 | + - name: Enable dry-run |
| 72 | + run: echo "RENOVATE_DRY_RUN=full" >>"${GITHUB_ENV}" |
| 73 | + if: inputs.dry_run || github.event_name == 'pull_request' |
| 74 | + |
| 75 | + - uses: actions/cache/restore@v4 |
| 76 | + id: cache |
| 77 | + with: |
| 78 | + key: ${{ env.cache_key }} |
| 79 | + restore-keys: | |
| 80 | + ${{ env.restore_key }} |
| 81 | + path: | |
| 82 | + ${{ env.cache_dir }} |
| 83 | +
|
| 84 | + # Unfortunately, the permissions expected within renovate's docker container |
| 85 | + # are different than the ones given after the cache is restored. We have to |
| 86 | + # change ownership to solve this. We also need to have correct permissions in |
| 87 | + # the entire /tmp/renovate tree, not just the section with the repo cache. |
| 88 | + # See https://github.com/marketplace/actions/renovate-bot-github-action#persisting-the-repository-cache |
| 89 | + - name: Fix cache permissions |
| 90 | + env: |
| 91 | + CACHE_DIR: ${{ env.cache_dir }} |
| 92 | + run: | |
| 93 | + mkdir -p "${CACHE_DIR}" |
| 94 | + sudo chown -R 12021:0 /tmp/renovate/ |
| 95 | +
|
| 96 | + # https://github.com/renovatebot |
| 97 | + - uses: renovatebot/github-action@a447f09147d00e00ae2a82ad5ef51ca89352da80 # v43.0.9 |
| 98 | + with: |
| 99 | + # https://docs.renovatebot.com/configuration-options |
| 100 | + # https://docs.renovatebot.com/self-hosted-configuration |
| 101 | + configurationFile: renovate-config.json |
| 102 | + token: ${{ steps.app_token.outputs.token }} |
| 103 | + renovate-version: ${{ env.RENOVATE_VERSION }} |
| 104 | + env: |
| 105 | + RENOVATE_DRY_RUN: ${{ env.RENOVATE_DRY_RUN }} |
| 106 | + RENOVATE_HOST_RULES: | |
| 107 | + [ |
| 108 | + { |
| 109 | + "hostType": "docker", |
| 110 | + "username": "${{ secrets.DOCKERHUB_USER }}", |
| 111 | + "password": "${{ secrets.DOCKERHUB_TOKEN }}" |
| 112 | + }, |
| 113 | + { |
| 114 | + "hostType": "docker", |
| 115 | + "matchHost": "ghcr.io", |
| 116 | + "username": "${{ github.actor }}", |
| 117 | + "password": "${{ secrets.GITHUB_TOKEN }}" |
| 118 | + } |
| 119 | + ] |
| 120 | +
|
| 121 | + - uses: actions/cache/save@v4 |
| 122 | + if: steps.cache.outputs.cache-hit != true && github.event_name != 'pull_request_target' && env.RENOVATE_DRY_RUN != 'full' |
| 123 | + with: |
| 124 | + key: ${{ env.cache_key }} |
| 125 | + path: | |
| 126 | + ${{ env.cache_dir }} |
0 commit comments