update-deps.yml 2.9 KB

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