Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add job to delete old/stale branches created by the automation #3245

Merged
merged 1 commit into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/chainguard/delete-branches.sts.yaml
@@ -0,0 +1,8 @@
issuer: https://token.actions.githubusercontent.com
subject: repo:wolfi-dev/advisories:ref:refs/heads/main
claim_pattern:
workflow_ref: wolfi-dev/advisories/.github/workflows/delete-old-branches.yaml@refs/heads/main

permissions:
contents: write
pull_requests: read
34 changes: 34 additions & 0 deletions .github/workflows/delete-old-branches.yaml
@@ -0,0 +1,34 @@
name: Delete old branches

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
cleanup_old_branches:
runs-on: ubuntu-latest

if: github.repository == 'wolfi-dev/advisories'

permissions:
id-token: write

steps:
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: ${{ github.repository }}
identity: delete-branches

- uses: wolfi-dev/actions/install-wolfictl@main

- name: Delete Branches that matches adv-
run: |
wolfictl gh gc branch https://github.com/wolfi-dev/advisories --match "adv-"
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}