Skip to content

Commit 6a638a0

Browse files
committed
workflows: Avoid cloning the project repo in prune-dist
There is no need to clone the project repository just to determine the SHA of current main. Use `git ls-remote` for that. Check for both "main" and "master" to keep this in sync with cockpit.git and other projects. Taken from cockpit-project/cockpit#15748
1 parent bf1daad commit 6a638a0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

.github/workflows/prune-dist.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ jobs:
1010
run:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Clone repository
14-
uses: actions/checkout@v2
15-
1613
- name: Set up configuration and secrets
1714
run: |
1815
printf '[user]\n\tname = Cockpit Project\n\[email protected]\n' > ~/.gitconfig
@@ -28,14 +25,15 @@ jobs:
2825
run: |
2926
set -ex
3027
31-
HEAD=$(git rev-parse HEAD)
28+
# head commit SHA of default branch
29+
HEAD=$(git ls-remote 'https://github.com/${{ github.repository }}' main master | cut -f1 | head -n1)
3230
3331
cd dist-repo
3432
now="$(date +%s)"
3533
for tag in $(git tag -l); do
3634
tag_time="$(git show -s --format=%at $tag)"
3735
if [ "$tag" = "sha-${HEAD}" ]; then
38-
echo "$tag refers to current project HEAD, keeping"
36+
echo "$tag refers to current project default branch HEAD, keeping"
3937
elif [ $((now - tag_time)) -ge 604800 ]; then
4038
echo "$tag is older than 7 days, deleting..."
4139
git push origin ":$tag"

0 commit comments

Comments
 (0)