update-deps.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. permissions:
  15. contents: read
  16. outputs:
  17. branches: ${{ steps.branches.outputs.branches }}
  18. steps:
  19. - uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
  20. with:
  21. egress-policy: audit
  22. - name: Checkout
  23. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  24. with:
  25. fetch-depth: 0
  26. ref: ${{ github.event.inputs.ref }}
  27. - name: set branches output
  28. id: branches
  29. run: echo "branches=[\"main\"]" >> $GITHUB_OUTPUT
  30. update-dependencies:
  31. permissions:
  32. contents: write # for Git to git push
  33. runs-on: ubuntu-latest
  34. needs: branches
  35. strategy:
  36. matrix:
  37. branch: ${{ fromJson(needs.branches.outputs.branches) }}
  38. steps:
  39. - uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
  40. with:
  41. egress-policy: audit
  42. # we can not use the default GHA token, as it prevents subsequent GHA
  43. # from running: we can create a PR but the tests won't run :/
  44. - name: Generate token
  45. id: generate_token
  46. uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
  47. with:
  48. app-id: ${{ secrets.APP_ID }}
  49. private-key: ${{ secrets.PRIVATE_KEY }}
  50. owner: ${{ github.repository_owner }}
  51. - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  52. with:
  53. token: ${{ steps.generate_token.outputs.token }}
  54. ref: ${{ matrix.branch }}
  55. fetch-depth: 0
  56. - name: Setup Go
  57. uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
  58. with:
  59. go-version-file: go.mod
  60. - name: create pull request
  61. env:
  62. BASE_BRANCH: ${{ matrix.branch }}
  63. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
  64. run: |
  65. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  66. git config --global user.name "External Secrets Operator"
  67. BRANCH=update-deps-$(date "+%s")
  68. make update-deps || true
  69. make check-diff || true
  70. if git diff-index --quiet HEAD --; then
  71. echo "nothing changed. skipping."
  72. exit 0;
  73. fi
  74. git checkout -b $BRANCH
  75. git add -A
  76. git commit -m "update dependencies" -s
  77. git push origin $BRANCH
  78. gh pr create -B $BASE_BRANCH -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'