clean_build_artifacts.yml 837 B

12345678910111213141516171819202122
  1. name: Clean build artifacts
  2. on:
  3. schedule:
  4. - cron: '0 10 * * *' # Once per day at 10am UTC
  5. permissions:
  6. contents: read
  7. jobs:
  8. main:
  9. permissions:
  10. contents: none
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Delete artifacts in cron job
  14. env:
  15. GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
  16. run: |
  17. echo "Running clean build artifacts logic"
  18. output=$(curl -X GET -H "Authorization: token $GH_ACTIONS_REPO_TOKEN" https://api.github.com/repos/spring-projects/spring-security/actions/artifacts | grep '"id"' | cut -d : -f2 | sed 's/,*$//g')
  19. echo Output is $output
  20. for id in $output; do curl -X DELETE -H "Authorization: token $GH_ACTIONS_REPO_TOKEN" https://api.github.com/repos/spring-projects/spring-security/actions/artifacts/$id; done;