Github actions for renovate to read AWS Code Artifact

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

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

  1. name: Renovate
  2. on:
  3. schedule:
  4. - cron: '*/10 * * * *'
  5. jobs:
  6. renovate:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - name: Checkout repository
  10. uses: actions/checkout@v2
  11. - name: Set up Node.js
  12. uses: actions/setup-node@v2
  13. with:
  14. node-version: 16
  15. - name: Install Renovate
  16. run: npm install -g renovate
  17. - name: Replace GitHub token in renovate-config.json
  18. run: sed -i 's/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g' renovate-config.json
  19. - name: Run Renovate
  20. run: renovate --config=renovate-config.json
  21. env:
  22. CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}

Here is the renovate-config.json file

  1. {
  2. "platform": "github",
  3. "endpoint": "https://api.github.com",
  4. "token": "<token>",
  5. "repositories": ["githubuser/repnoname"],
  6. "packageRules": [
  7. {
  8. "matchDatasources": ["maven"],
  9. "registryUrls": [
  10. "https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
  11. ]
  12. }
  13. ]
  14. }

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

  1. renovate --config=renovate-config.json
  2. shell: /usr/bin/bash -e {0}
  3. env:
  4. CODEARTIFACT_AUTH_TOKEN: ***
  5. WARN: Config needs migrating
  6. "originalConfig": {
  7. "platform": "github",
  8. "endpoint": "https://api.github.com",
  9. "repositories": ["githubuser/reponame"],
  10. "packageRules": [
  11. {
  12. "matchDatasources": ["maven"],
  13. "registryUrls": [
  14. "https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
  15. ]
  16. }
  17. ]
  18. },
  19. "migratedConfig": {
  20. "platform": "github",
  21. "endpoint": "https://api.github.com",
  22. "repositories": ["githubusr/reponame"],
  23. "packageRules": [
  24. {
  25. "matchDatasources": ["maven"],
  26. "registryUrls": [
  27. "https://domain-12345678.d.codeartifact.us-east-1.amazonaws.com/maven/repo/"
  28. ]
  29. }
  30. ]
  31. error: unknown option '--config=renovate-config.json'
  32. 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

  1. name: Renovate
  2. on:
  3. schedule:
  4. - cron: &#39;*/10 * * * *&#39;
  5. jobs:
  6. renovate:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - name: Checkout repository
  10. uses: actions/checkout@v2
  11. - name: Set up Node.js
  12. uses: actions/setup-node@v2
  13. with:
  14. node-version: 16
  15. - name: Install Renovate
  16. run: npm install -g renovate
  17. - name: Replace GitHub token in renovate-config.json
  18. run: sed -i &#39;s/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g&#39; renovate-config.json
  19. - name: Run Renovate
  20. run: renovate --config=renovate-config.json
  21. env:
  22. CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}

Here is the renovate-config.json file

  1. {
  2. &quot;platform&quot;: &quot;github&quot;,
  3. &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  4. &quot;token&quot;: &quot;&lt;token&gt;&quot;,
  5. &quot;repositories&quot;: [&quot;githubuser/repnoname&quot;],
  6. &quot;packageRules&quot;: [
  7. {
  8. &quot;matchDatasources&quot;: [&quot;maven&quot;],
  9. &quot;registryUrls&quot;: [
  10. &quot;https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
  11. ]
  12. }
  13. ]
  14. }

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

  1. renovate --config=renovate-config.json
  2. shell: /usr/bin/bash -e {0}
  3. env:
  4. CODEARTIFACT_AUTH_TOKEN: ***
  5. WARN: Config needs migrating
  6. &quot;originalConfig&quot;: {
  7. &quot;platform&quot;: &quot;github&quot;,
  8. &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  9. &quot;repositories&quot;: [&quot;githubuser/reponame&quot;],
  10. &quot;packageRules&quot;: [
  11. {
  12. &quot;matchDatasources&quot;: [&quot;maven&quot;],
  13. &quot;registryUrls&quot;: [
  14. &quot;https://domain-123456789.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
  15. ]
  16. }
  17. ]
  18. },
  19. &quot;migratedConfig&quot;: {
  20. &quot;platform&quot;: &quot;github&quot;,
  21. &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  22. &quot;repositories&quot;: [&quot;githubusr/reponame&quot;],
  23. &quot;packageRules&quot;: [
  24. {
  25. &quot;matchDatasources&quot;: [&quot;maven&quot;],
  26. &quot;registryUrls&quot;: [
  27. &quot;https://domain-12345678.d.codeartifact.us-east-1.amazonaws.com/maven/repo/&quot;
  28. ]
  29. }
  30. ]
  31. }
  32. error: unknown option &#39;--config=renovate-config.json&#39;
  33. 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

以下是翻译好的部分:

  1. name: Renovate
  2. on:
  3. schedule:
  4. - cron: '*/10 * * * *' # 根据您的偏好设置计划
  5. jobs:
  6. renovate:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - name: 检出存储库
  10. uses: actions/checkout@v2
  11. - name: 设置 Node.js
  12. uses: actions/setup-node@v2
  13. with:
  14. node-version: 18.12.0
  15. - name: 安装 Renovate
  16. run: npm install -g renovate
  17. - name: renovate-config.json 中替换 GitHub 令牌
  18. run: sed -i 's/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g' renovate-config.json
  19. - name: renovate-config.json 中替换 CodeArtifact 令牌
  20. run: sed -i 's/REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN/${{ secrets.CODEARTIFACT_AUTH_TOKEN }}/g' renovate-config.json
  21. - name: 运行 Renovate
  22. run: renovate
  23. env:
  24. RENOVATE_CONFIG_FILE: renovate-config.json
  25. CODEARTIFACT_AUTH_TOKEN: ${{ secrets.CODEARTIFACT_AUTH_TOKEN }}
  1. {
  2. "platform": "github",
  3. "endpoint": "https://api.github.com",
  4. "token": "<github token>",
  5. "enabled": true,
  6. "repositories": ["repoOwner/repoName"],
  7. "dependencyDashboard": true,
  8. "repositoryCache": "gradle-test-renovate-cache",
  9. "packageRules": [
  10. {
  11. "matchDatasources": ["maven"],
  12. "registryUrls": [
  13. "https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/"
  14. ]
  15. }
  16. ],
  17. "hostRules": [
  18. {
  19. "hostType": "maven",
  20. "baseUrl": "https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/",
  21. "token": "REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN"
  22. }
  23. ]
  24. }
  1. {
  2. "enabled": true
  3. }

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

英文:

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)

  1. name: Renovate
  2. on:
  3. schedule:
  4. - cron: &#39;*/10 * * * *&#39; # Set the schedule according to your preference
  5. jobs:
  6. renovate:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - name: Checkout repository
  10. uses: actions/checkout@v2
  11. - name: Set up Node.js
  12. uses: actions/setup-node@v2
  13. with:
  14. node-version: 18.12.0
  15. - name: Install Renovate
  16. run: npm install -g renovate
  17. - name: Replace GitHub token in renovate-config.json
  18. run: sed -i &#39;s/REPLACE_WITH_GITHUB_TOKEN/${{ secrets.GITHUB_TOKEN }}/g&#39; renovate-config.json
  19. - name: Replace CodeArtifact token in renovate-config.json
  20. run: sed -i &#39;s/REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN/${{ secrets.CODEARTIFACT_AUTH_TOKEN }}/g&#39; renovate-config.json
  21. - name: Run Renovate
  22. run: renovate
  23. env:
  24. RENOVATE_CONFIG_FILE: renovate-config.json
  25. 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)

  1. {
  2. &quot;platform&quot;: &quot;github&quot;,
  3. &quot;endpoint&quot;: &quot;https://api.github.com&quot;,
  4. &quot;token&quot;: &quot;&lt;github token&gt;&quot;,
  5. &quot;enabled&quot;: true,
  6. &quot;repositories&quot;: [&quot;repoOwner/repoName&quot;],
  7. &quot;dependencyDashboard&quot;: true,
  8. &quot;repositoryCache&quot;: &quot;gradle-test-renovate-cache&quot;,
  9. &quot;packageRules&quot;: [
  10. {
  11. &quot;matchDatasources&quot;: [&quot;maven&quot;],
  12. &quot;registryUrls&quot;: [
  13. &quot;https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/&quot;
  14. ]
  15. }
  16. ],
  17. &quot;hostRules&quot;: [
  18. {
  19. &quot;hostType&quot;: &quot;maven&quot;,
  20. &quot;baseUrl&quot;: &quot;https://domain-domainOwner.d.codeartifact.region.amazonaws.com/maven/repository/&quot;,
  21. &quot;token&quot;: &quot;REPLACE_WITH_CODEARTIFACT_AUTH_TOKEN&quot;
  22. }
  23. ]
  24. }

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

  1. {
  2. &quot;enabled&quot;: true
  3. }

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:

确定