sri.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: SRI hashes
  2. # Regenerates the subresource integrity (SRI) hashes in lib/Configuration.php
  3. # after anything got merged or pushed into master and commits them, if they
  4. # changed. The push uses a deploy key (secret SRI_DEPLOY_KEY) that may bypass
  5. # the branch ruleset of master.
  6. on:
  7. push:
  8. branches: [ master ]
  9. paths:
  10. - 'js/*.js'
  11. - 'lib/Configuration.php'
  12. - 'bin/sri'
  13. - '.github/workflows/sri.yml'
  14. workflow_dispatch:
  15. permissions: {}
  16. # run one update at a time; a queued run checks out the latest master anyway
  17. concurrency:
  18. group: sri-hashes
  19. cancel-in-progress: false
  20. jobs:
  21. update:
  22. name: Update SRI hashes
  23. if: github.repository == 'PrivateBin/PrivateBin'
  24. runs-on: ubuntu-latest
  25. permissions:
  26. contents: read
  27. steps:
  28. - name: Checkout
  29. uses: actions/checkout@v7
  30. with:
  31. ref: master
  32. ssh-key: ${{ secrets.SRI_DEPLOY_KEY }}
  33. # the deploy key is needed for the push below, no third party actions get run after this
  34. persist-credentials: true
  35. - name: Update SRI hashes
  36. run: php bin/sri
  37. - name: Commit and push changed hashes
  38. run: |
  39. if git diff --quiet -- lib/Configuration.php; then
  40. echo "SRI hashes are up to date, nothing to commit."
  41. exit 0
  42. fi
  43. git config user.name 'PrivateBin SRI Bot'
  44. git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
  45. git commit --message 'chore: update SRI hashes' -- lib/Configuration.php
  46. git push origin HEAD:master