Github actions for renovate to read AWS Code Artifact

huangapple go评论64阅读模式
英文:

Github actions for renovate to read AWS Code Artifact

问题

以下是您要翻译的内容:

We have a kotlin based repo in github and we are using AWS Code Artifact to store our private packages. I am trying to use renovate to check for dependency updates from AWS Code Artifact and create pull requests accordingly.

Knowing the fact that Renovate Bot (managed one) doesnt support the AWS Code Artifact, so I am trying to create a CICD for this and self host it using github actions. Below is my renovate.yml file content

name: Renovate
on:
  schedule:
    - cron: '*/10 * * * *'

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Install Renovate
        run: npm install -g renovate

      - name: Replace GitHub token in renovate-config.json
        run: sed -i 's/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g' renovate-config.json

      - name: Run Renovate
        run: renovate --config=renovate-config.json
        env:
          CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}

Here is the renovate-config.json file

{
  "platform": "github",
  "endpoint": "https://api.github.com",
  "token": "<token>",
  "repositories": ["githubuser/repnoname"],
  "packageRules": [
    {
      "matchDatasources": ["maven"],
      "registryUrls": [
        "https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
      ]
    }
  ]
}

But when the github actions running it is keep showing this error

renovate --config=renovate-config.json
  shell: /usr/bin/bash -e {0}
  env:
    CODEARTIFACT_AUTH_TOKEN: ***
 WARN: Config needs migrating
       "originalConfig": {
         "platform": "github",
         "endpoint": "https://api.github.com",
         "repositories": ["githubuser/reponame"],
         "packageRules": [
           {
             "matchDatasources": ["maven"],
             "registryUrls": [
               "https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
             ]
           }
         ]
       },
       "migratedConfig": {
         "platform": "github",
         "endpoint": "https://api.github.com",
         "repositories": ["githubusr/reponame"],
         "packageRules": [
           {
             "matchDatasources": ["maven"],
             "registryUrls": [
               "https://domain-12345678.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
             ]
           }
         ]
    error: unknown option '--config=renovate-config.json'
Error: Process completed with exit code 1.

Any idea why? or is there any other way of doing the same. Ultimate goal is to config renovate to access AWS Code artifacts so it can create related PRs.

英文:

We have a kotlin based repo in github and we are using AWS Code Artifact to store our private packages. I am trying to use renovate to check for dependency updates from AWS Code Artifact and create pull requests accordingly.

Knowing the fact that Renovate Bot (managed one) doesnt support the AWS Code Artifact, so I am trying to create a CICD for this and self host it using github actions. Below is my renovate.yml file content

name: Renovate
on:
  schedule:
    - cron: &#39;*/10 * * * *&#39;

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Install Renovate
        run: npm install -g renovate

      - name: Replace GitHub token in renovate-config.json
        run: sed -i &#39;s/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g&#39; renovate-config.json

      - name: Run Renovate
        run: renovate --config=renovate-config.json
        env:
          CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}

Here is the renovate-config.json file

{
  &quot;platform&quot;: &quot;github&quot;,
  &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  &quot;token&quot;: &quot;&lt;token&gt;&quot;,
  &quot;repositories&quot;: [&quot;githubuser/repnoname&quot;],
  &quot;packageRules&quot;: [
    {
      &quot;matchDatasources&quot;: [&quot;maven&quot;],
      &quot;registryUrls&quot;: [
        &quot;https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
      ]
    }
  ]
}

But when the github actions running it is keep showing this error

 renovate --config=renovate-config.json
  shell: /usr/bin/bash -e {0}
  env:
    CODEARTIFACT_AUTH_TOKEN: ***
 WARN: Config needs migrating
       &quot;originalConfig&quot;: {
         &quot;platform&quot;: &quot;github&quot;,
         &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
         &quot;repositories&quot;: [&quot;githubuser/reponame&quot;],
         &quot;packageRules&quot;: [
           {
             &quot;matchDatasources&quot;: [&quot;maven&quot;],
             &quot;registryUrls&quot;: [
               &quot;https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
             ]
           }
         ]
       },
       &quot;migratedConfig&quot;: {
         &quot;platform&quot;: &quot;github&quot;,
         &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
         &quot;repositories&quot;: [&quot;githubusr/reponame&quot;],
         &quot;packageRules&quot;: [
           {
             &quot;matchDatasources&quot;: [&quot;maven&quot;],
             &quot;registryUrls&quot;: [
               &quot;https://domain-12345678.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
             ]
           }
         ]
       }
error: unknown option &#39;--config=renovate-config.json&#39;
Error: Process completed with exit code 1.

Any idea why? or is there any other way of doing the same. Ultimate goal is to config renovate to access AWS Code artifacts so it can create related PRs.

答案1

得分: 1

以下是翻译好的部分:

name: Renovate
on:
  schedule:
    - cron: '*/10 * * * *' # 根据您的偏好设置计划

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: 检出存储库
        uses: actions/checkout@v2

      - name: 设置 Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 18.12.0

      - name: 安装 Renovate
        run: npm install -g renovate

      - name: 在 renovate-config.json 中替换 GitHub 令牌
        run: sed -i 's/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g' renovate-config.json

      - name: 在 renovate-config.json 中替换 CodeArtifact 令牌
        run: sed -i 's/REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN/${{ secrets.CODEARTIFACT_AUTH_TOKEN }}/g' renovate-config.json

      - name: 运行 Renovate
        run: renovate
        env:
          RENOVATE_CONFIG_FILE: renovate-config.json
          CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}
{
  "platform": "github",
  "endpoint": "https://api.github.com",
  "token": "<github token>",
  "enabled": true,
  "repositories": ["repoOwner/repoName"],
  "dependencyDashboard": true,
  "repositoryCache": "gradle-test-renovate-cache",
  "packageRules": [
    {
      "matchDatasources": ["maven"],
      "registryUrls": [
        "https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/"
      ]
    }
  ],
  "hostRules": [
    {
      "hostType": "maven",
      "baseUrl": "https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/",
      "token": "REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN"
    }
  ]
}
{
  "enabled": true
}

希望这对您有所帮助。谢谢。

英文:

Ok here I am posting a complete working solution with self hosted renovate on github actions. Please note that this solution is for Kotlin/Gradle/Maven based repos.

Inside .github/workflows create a renovate.yml file with the following content. Change the placeholder values according to your needs. (Keep REPLACE_WITH_GITHUB_TOKEN and REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN as it is)

name: Renovate
on:
  schedule:
    - cron: &#39;*/10 * * * *&#39; # Set the schedule according to your preference

jobs:
  renovate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 18.12.0

      - name: Install Renovate
        run: npm install -g renovate

      - name: Replace GitHub token in renovate-config.json
        run: sed -i &#39;s/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g&#39; renovate-config.json

      - name: Replace CodeArtifact token in renovate-config.json
        run: sed -i &#39;s/REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN/${{ secrets.CODEARTIFACT_AUTH_TOKEN }}/g&#39; renovate-config.json

      - name: Run Renovate
        run: renovate
        env:
          RENOVATE_CONFIG_FILE: renovate-config.json
          CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}

Now in the root of your repo create a file named renovate-config.json with the following content. ( Keep REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN here as it is too)

{
  &quot;platform&quot;: &quot;github&quot;,
  &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  &quot;token&quot;: &quot;&lt;github token&gt;&quot;,
  &quot;enabled&quot;: true,
  &quot;repositories&quot;: [&quot;repoOwner/repoName&quot;],
  &quot;dependencyDashboard&quot;: true,
  &quot;repositoryCache&quot;: &quot;gradle-test-renovate-cache&quot;,
  &quot;packageRules&quot;: [
    {
      &quot;matchDatasources&quot;: [&quot;maven&quot;],
      &quot;registryUrls&quot;: [
        &quot;https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/&quot;
      ]
    }
  ],
  &quot;hostRules&quot;: [
    {
      &quot;hostType&quot;: &quot;maven&quot;,
      &quot;baseUrl&quot;: &quot;https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/&quot;,
      &quot;token&quot;: &quot;REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN&quot;
    }
  ]
}

This should be enough to make it work. Also if you have enabled the renovate bot on this repo or on the organizational level then in the root of repo you will see a file named " renovate.json ". Replace the content of that file with the following

{
  &quot;enabled&quot;: true
}

Hope this will help. Thanks

huangapple
  • 本文由 发表于 2023年3月31日 17:08:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896694.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定