Skip to content

Commit 739d070

Browse files
authored
ci: comply with enterprise Actions policy
2 parents 4491269 + 75b7484 commit 739d070

2 files changed

Lines changed: 37 additions & 13 deletions

File tree

‎.github/workflows/delete-old-branches.yml‎

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,38 @@ jobs:
88
delete-old-branches:
99
name: Delete old branches
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: read
1114
steps:
12-
- name: Checkout repository
13-
uses: actions/checkout@v2
14-
- name: Run delete-old-branches-action
15-
uses: beatlabs/delete-old-branches-action@v0.0.10
16-
with:
17-
repo_token: ${{ github.token }}
18-
date: '7 days ago'
19-
dry_run: false
20-
default_branches: main,master,staging
21-
exclude_open_pr_branches: true
15+
- name: Delete branches with no activity in 7+ days
16+
env:
17+
GH_TOKEN: ${{ github.token }}
18+
REPO: ${{ github.repository }}
19+
PROTECTED: 'main master staging'
20+
CUTOFF_DAYS: '7'
21+
run: |
22+
set -euo pipefail
23+
24+
cutoff_epoch=$(date -u -d "${CUTOFF_DAYS} days ago" +%s)
25+
26+
# Branches with open PRs (head refs) — never delete these.
27+
open_pr_branches=$(gh api --paginate "repos/${REPO}/pulls?state=open&per_page=100" \
28+
--jq '.[].head.ref' | sort -u)
29+
30+
# All branches with their tip commit date, paginated.
31+
gh api --paginate "repos/${REPO}/branches?per_page=100" --jq '.[].name' | while read -r branch; do
32+
case " ${PROTECTED} " in *" ${branch} "*) continue ;; esac
33+
if grep -Fxq "${branch}" <<< "${open_pr_branches}"; then
34+
continue
35+
fi
36+
37+
committed_at=$(gh api "repos/${REPO}/branches/${branch}" \
38+
--jq '.commit.commit.committer.date')
39+
committed_epoch=$(date -u -d "${committed_at}" +%s)
40+
41+
if [ "${committed_epoch}" -lt "${cutoff_epoch}" ]; then
42+
echo "Deleting ${branch} (last commit ${committed_at})"
43+
gh api -X DELETE "repos/${REPO}/git/refs/heads/${branch}"
44+
fi
45+
done

‎.github/workflows/maven.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
publish:
1212
name: Publish to Maven Central
13-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-latest-large
1414
permissions:
1515
contents: read
1616

@@ -21,10 +21,10 @@ jobs:
2121

2222
steps:
2323
- name: Checkout
24-
uses: actions/checkout@v5
24+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
2525

2626
- name: Set up Java & Maven for Central
27-
uses: actions/setup-java@v4
27+
uses: actions/setup-java@d7793b545071e98d581d3bf084a51c3213318a07 # v4
2828
with:
2929
distribution: 'temurin'
3030
java-version: '8'

0 commit comments

Comments
 (0)