update-deps.yml 2.8 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@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
  18. with:
  19. egress-policy: audit
  20. - name: Checkout
  21. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  22. with:
  23. fetch-depth: 0
  24. ref: ${{ github.event.inputs.ref }}
  25. - name: set branches output
  26. id: branches
  27. # outputs the second to most recent `release-x.y` branches plus `main` as JSON
  28. run: |
  29. echo "branches=$(git branch -a | grep -E "remotes/origin/(main|release-)" | sed 's/ remotes\/origin\///' | sort -V | tail -2 | head -1 | jq -R -s -c 'split("\n") | map(select(length > 0)) | . + ["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@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
  40. with:
  41. egress-policy: audit
  42. - name: Setup Go
  43. uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
  44. with:
  45. go-version: "1.24"
  46. # we can not use the default GHA token, as it prevents subsequent GHA
  47. # from running: we can create a PR but the tests won't run :/
  48. - name: Generate token
  49. id: generate_token
  50. uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
  51. with:
  52. app_id: ${{ secrets.APP_ID }}
  53. private_key: ${{ secrets.PRIVATE_KEY }}
  54. - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  55. with:
  56. token: ${{ steps.generate_token.outputs.token }}
  57. ref: ${{ matrix.branch }}
  58. fetch-depth: 0
  59. - name: create pull request
  60. run: |
  61. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  62. git config --global user.name "External Secrets Operator"
  63. BRANCH=update-deps-$(date "+%s")
  64. make update-deps || true
  65. make check-diff || true
  66. if git diff-index --quiet HEAD --; then
  67. echo "nothing changed. skipping."
  68. exit 0;
  69. fi
  70. git checkout -b $BRANCH
  71. git add -A
  72. git commit -m "update dependencies" -s
  73. git push origin $BRANCH
  74. gh pr create -B ${{ matrix.branch }} -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'
  75. env:
  76. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}