clean_build_artifacts.yml 907 B

1234567891011121314151617181920212223
  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. runs-on: ubuntu-latest
  10. if: ${{ github.repository == 'spring-projects/spring-security' }}
  11. permissions:
  12. contents: none
  13. steps:
  14. - name: Delete artifacts in cron job
  15. env:
  16. GH_ACTIONS_REPO_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }}
  17. run: |
  18. echo "Running clean build artifacts logic"
  19. 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')
  20. echo Output is $output
  21. 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;