update-deps.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
  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@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
  38. with:
  39. egress-policy: audit
  40. - name: Setup Go
  41. uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.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@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
  49. with:
  50. app-id: ${{ secrets.APP_ID }}
  51. private-key: ${{ secrets.PRIVATE_KEY }}
  52. owner: ${{ github.repository_owner }}
  53. - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
  54. with:
  55. token: ${{ steps.generate_token.outputs.token }}
  56. ref: ${{ matrix.branch }}
  57. fetch-depth: 0
  58. - name: create pull request
  59. run: |
  60. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  61. git config --global user.name "External Secrets Operator"
  62. BRANCH=update-deps-$(date "+%s")
  63. make update-deps || true
  64. make check-diff || true
  65. if git diff-index --quiet HEAD --; then
  66. echo "nothing changed. skipping."
  67. exit 0;
  68. fi
  69. git checkout -b $BRANCH
  70. git add -A
  71. git commit -m "update dependencies" -s
  72. git push origin $BRANCH
  73. gh pr create -B ${{ matrix.branch }} -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'
  74. env:
  75. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}