From 4d464ddf09fc547dd7aa3884bbaedd83ca69aada Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 15 Nov 2021 20:42:34 -0500 Subject: [PATCH] ci: merge removal of workflows with `stale.yml` and remove untagged docker images on `release` only --- .github/workflows/clean.yml | 20 ++++++++++++++ .github/workflows/maintenance.yml | 46 ------------------------------- .github/workflows/stale.yml | 16 +++++++++-- 3 files changed, 34 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/clean.yml delete mode 100644 .github/workflows/maintenance.yml diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 00000000..81b68045 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,20 @@ +name: Clean untagged docker images from ghcr.io + +on: + release: + - published + workflow_dispatch: + +jobs: + clean: + name: Clean untagged docker images from ghcr.io + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Run script + run: ./delete_ghcr_dangling_images.sh lowlighter metrics + working-directory: .github/workflows/maintenance + env: + GITHUB_TOKEN: ${{ secrets.GHCR_BOT_TOKEN }} diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml deleted file mode 100644 index b3344e34..00000000 --- a/.github/workflows/maintenance.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Maintenance ๐Ÿงฐ - -on: - schedule: - - cron: "30 2 * * *" - workflow_dispatch: - -jobs: - workflow_removal: - runs-on: ubuntu-latest - name: Workflow cleanup ๐Ÿงน๐Ÿ‘ทโ€โ™‚๏ธ - # Errors will probably be caused by excesses in API quota, so we can safely continue. - # Remaining workflows will be removed in the next scheduled run. - continue-on-error: true - steps: - - name: Clone repository - uses: actions/checkout@v2.3.4 - - - name: Run deletion script ๐Ÿ—‘ - run: ./delete_workflows.sh lowlighter/metrics - working-directory: ./.github/workflows/maintenance - env: - GITHUB_TOKEN: ${{ github.token }} - - dangling_images_removal: - runs-on: ubuntu-latest - name: Cleanup dangling images from GHCR ๐Ÿงน๐Ÿ“ฆ - # Errors will probably be caused by excesses in API quota, so we can safely continue. - # Remaining workflows will be removed in the next scheduled run. - continue-on-error: true - # Pay attention that the org name is not necessary here, as gh will automatically take the one from the logged in user. - strategy: - fail-fast: false - matrix: - container: - - 'metrics' - - steps: - - name: Clone repository - uses: actions/checkout@v2.3.4 - - - name: Run deletion script ๐Ÿ—‘ - run: ./delete_ghcr_dangling_images.sh lowlighter ${{ matrix.container }} - working-directory: ./.github/workflows/maintenance - env: - GITHUB_TOKEN: ${{ secrets.GHCR_BOT_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 34ff3037..3ab99390 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: Stale issue and pull requests +name: Stale issues, pull requests and workflow runs on: schedule: @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/stale@v3 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ github.token }} stale-pr-message: This pull request seems to be inactive and will be automatically closed in a few days if it remains without any activity. days-before-pr-stale: 21 days-before-pr-close: 3 @@ -34,3 +34,15 @@ jobs: pr-lock-inactive-days: 14 pr-lock-reason: "" pr-lock-labels: โ˜‘๏ธ archived + workflows: + name: Remove expired workflow runs + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Run script + run: ./delete_workflows.sh lowlighter/metrics + working-directory: .github/workflows/maintenance + env: + GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file