update-deps.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
  18. with:
  19. egress-policy: audit
  20. - name: Checkout
  21. uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
  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@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
  38. with:
  39. egress-policy: audit
  40. # we can not use the default GHA token, as it prevents subsequent GHA
  41. # from running: we can create a PR but the tests won't run :/
  42. - name: Generate token
  43. id: generate_token
  44. uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
  45. with:
  46. app-id: ${{ secrets.APP_ID }}
  47. private-key: ${{ secrets.PRIVATE_KEY }}
  48. owner: ${{ github.repository_owner }}
  49. - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
  50. with:
  51. token: ${{ steps.generate_token.outputs.token }}
  52. ref: ${{ matrix.branch }}
  53. fetch-depth: 0
  54. - name: Setup Go
  55. uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
  56. with:
  57. go-version-file: go.mod
  58. - name: create pull request
  59. env:
  60. BASE_BRANCH: ${{ matrix.branch }}
  61. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
  62. run: |
  63. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  64. git config --global user.name "External Secrets Operator"
  65. BRANCH=update-deps-$(date "+%s")
  66. make update-deps || true
  67. make check-diff || true
  68. if git diff-index --quiet HEAD --; then
  69. echo "nothing changed. skipping."
  70. exit 0;
  71. fi
  72. git checkout -b $BRANCH
  73. git add -A
  74. git commit -m "update dependencies" -s
  75. git push origin $BRANCH
  76. gh pr create -B $BASE_BRANCH -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'