update-deps.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: "Update dependencies"
  2. on:
  3. schedule:
  4. # Monday, 10AM UTC
  5. - cron: "0 10 * * 1"
  6. workflow_dispatch:
  7. inputs: {}
  8. permissions:
  9. contents: read
  10. jobs:
  11. branches:
  12. name: get branch data
  13. runs-on: ubuntu-latest
  14. outputs:
  15. branches: ${{ steps.branches.outputs.branches }}
  16. steps:
  17. - uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
  18. with:
  19. egress-policy: audit
  20. - name: Checkout
  21. uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
  22. with:
  23. fetch-depth: 0
  24. ref: ${{ github.event.inputs.ref }}
  25. - name: set branches output
  26. id: branches
  27. run: echo "branches=[\"main\"]" >> $GITHUB_OUTPUT
  28. update-dependencies:
  29. permissions:
  30. contents: write # for Git to git push
  31. runs-on: ubuntu-latest
  32. needs: branches
  33. strategy:
  34. matrix:
  35. branch: ${{ fromJson(needs.branches.outputs.branches) }}
  36. steps:
  37. - uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
  38. with:
  39. egress-policy: audit
  40. - name: Setup Go
  41. uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
  42. with:
  43. go-version: "1.24"
  44. # we can not use the default GHA token, as it prevents subsequent GHA
  45. # from running: we can create a PR but the tests won't run :/
  46. - name: Generate token
  47. id: generate_token
  48. uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
  49. with:
  50. app-id: ${{ secrets.APP_ID }}
  51. private-key: ${{ secrets.PRIVATE_KEY }}
  52. - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
  53. with:
  54. token: ${{ steps.generate_token.outputs.token }}
  55. ref: ${{ matrix.branch }}
  56. fetch-depth: 0
  57. - name: create pull request
  58. run: |
  59. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  60. git config --global user.name "External Secrets Operator"
  61. BRANCH=update-deps-$(date "+%s")
  62. make update-deps || true
  63. make check-diff || true
  64. if git diff-index --quiet HEAD --; then
  65. echo "nothing changed. skipping."
  66. exit 0;
  67. fi
  68. git checkout -b $BRANCH
  69. git add -A
  70. git commit -m "update dependencies" -s
  71. git push origin $BRANCH
  72. gh pr create -B ${{ matrix.branch }} -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'
  73. env:
  74. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}