update-deps.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. - name: Checkout
  18. uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  19. with:
  20. fetch-depth: 0
  21. ref: ${{ github.event.inputs.ref }}
  22. - name: set branches output
  23. id: branches
  24. # outputs the second to most recent `release-x.y` branches plus `main` as JSON
  25. run: |
  26. 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
  27. update-dependencies:
  28. permissions:
  29. contents: write # for Git to git push
  30. runs-on: ubuntu-latest
  31. needs: branches
  32. strategy:
  33. matrix:
  34. branch: ${{ fromJson(needs.branches.outputs.branches) }}
  35. steps:
  36. - name: Setup Go
  37. uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
  38. with:
  39. go-version: "1.21"
  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: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
  45. with:
  46. app_id: ${{ secrets.APP_ID }}
  47. private_key: ${{ secrets.PRIVATE_KEY }}
  48. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  49. with:
  50. token: ${{ steps.generate_token.outputs.token }}
  51. ref: ${{ matrix.branch }}
  52. fetch-depth: 0
  53. - name: create pull request
  54. run: |
  55. git config --global user.email "ExternalSecretsOperator@users.noreply.github.com"
  56. git config --global user.name "External Secrets Operator"
  57. BRANCH=update-deps-$(date "+%s")
  58. make update-deps || true
  59. if git diff-index --quiet HEAD --; then
  60. echo "nothing changed. skipping."
  61. exit 0;
  62. fi
  63. git checkout -b $BRANCH
  64. git add -A
  65. git commit -m "update dependencies" -s
  66. git push origin $BRANCH
  67. gh pr create -B ${{ matrix.branch }} -H ${BRANCH} --title 'chore: update dependencies' --body 'Update dependencies'
  68. env:
  69. GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}