update-deps.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. name: "Update dependencies"
  2. on:
  3. schedule:
  4. # Monday, 10AM UTC
  5. - cron: "0 10 * * 1"
  6. workflow_dispatch:
  7. inputs: {}
  8. jobs:
  9. branches:
  10. name: get branch data
  11. runs-on: ubuntu-latest
  12. outputs:
  13. branches: ${{ steps.branches.outputs.branches }}
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v4
  17. with:
  18. fetch-depth: 0
  19. ref: ${{ github.event.inputs.ref }}
  20. - name: set branches output
  21. id: branches
  22. # outputs the second to most recent `release-x.y` branches plus `main` as JSON
  23. run: |
  24. 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
  25. update-dependencies:
  26. runs-on: ubuntu-latest
  27. needs: branches
  28. strategy:
  29. matrix:
  30. branch: ${{ fromJson(needs.branches.outputs.branches) }}
  31. steps:
  32. - name: Setup Go
  33. uses: actions/setup-go@v4
  34. with:
  35. go-version: "1.21"
  36. # we can not use the default GHA token, as it prevents subsequent GHA
  37. # from running: we can create a PR but the tests won't run :/
  38. - name: Generate token
  39. id: generate_token
  40. uses: tibdex/github-app-token@v2
  41. with:
  42. app_id: ${{ secrets.APP_ID }}
  43. private_key: ${{ secrets.PRIVATE_KEY }}
  44. - uses: actions/checkout@v4
  45. with:
  46. token: ${{ steps.generate_token.outputs.token }}
  47. ref: ${{ matrix.branch }}
  48. fetch-depth: 0
  49. - name: create pull request
  50. run: |
  51. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  52. git config --global user.name "External Secrets Operator"
  53. BRANCH=update-deps-$(date "+%s")
  54. make update-deps || true
  55. if git diff-index --quiet HEAD --; then
  56. echo "nothing changed. skipping."
  57. exit 0;
  58. fi
  59. git checkout -b $BRANCH
  60. git add -A
  61. git commit -m "update dependencies" -s
  62. git push origin $BRANCH
  63. gh pr create -B ${{ matrix.branch }} -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'
  64. env:
  65. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}