Delete old folders from github pages #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete old folders from github pages | |
on: | |
schedule: | |
- cron: '0 0 */3 * *' # Runs at 12:00 AM UTC every 3 days | |
workflow_dispatch: | |
inputs: | |
n_days: | |
description: 'Number of days to determine which folders to delete. Example: 10 will delete all folders older than 10 days' | |
required: true | |
default: "1" | |
folder_name: | |
description: 'Name of the folder where you store the reports. Default is root' | |
required: true | |
default: '.' | |
jobs: | |
delete_old_folders: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Pray then Run the script | |
run: python rm_old_folders.py --n-days ${{ github.event.inputs.n_days }} --folder-name ${{ github.event.inputs.folder_name }} | |
- name: Commit all changed files back to the repository | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
branch: gh-pages | |
commit_message: Delete folders older than ${{ github.event.inputs.n_days }} days |