Skip to content

Commit 460fdea

Browse files
authored
Refine conditions for deleting binaries
1 parent bb09904 commit 460fdea

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

.github/workflows/cleanup-pr.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,53 @@ on:
66

77
jobs:
88
cleanup:
9-
if: github.repository == 'JabRef/jabref'
9+
if: github.event.pull_request.head.repo.full_name == 'JabRef/jabref'
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: read
1313
packages: write
1414
steps:
15-
- name: Cancel deployment run
15+
- name: Cancel workflow "binaries" run
1616
uses: styfle/[email protected]
1717
with:
1818
ignore_sha: true
19-
workflow_id: 9813 # workflow "Deployment"
20-
- name: Check secrets presence
21-
id: checksecrets
22-
shell: bash
19+
workflow_id: 9160969135
20+
- name: Cancel workflow "binaries (ea)" run
21+
uses: styfle/[email protected]
22+
with:
23+
ignore_sha: true
24+
workflow_id: 160969125
25+
- name: "Check for 'dev: binaries' label"
26+
id: check_label
2327
run: |
24-
if [ "$BUILDJABREFPRIVATEKEY" == "" ]; then
25-
echo "secretspresent=NO" >> $GITHUB_OUTPUT
26-
echo "❌ Secret BUILDJABREFPRIVATEKEY not present"
28+
labels=$(gh pr view ${{ github.event.pull_request.number }} --json labels -q '.labels[].name')
29+
if echo "$labels" | grep -Fxq "dev: binaries"; then
30+
echo "has_label_binaries=yes" >> $GITHUB_OUTPUT
2731
else
28-
echo "secretspresent=YES" >> $GITHUB_OUTPUT
29-
echo "✔️ Secret BUILDJABREFPRIVATEKEY present"
32+
echo "has_label_binaries=no" >> $GITHUB_OUTPUT
3033
fi
3134
env:
32-
BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3336
- name: Delete folder on builds.jabref.org
34-
if: steps.checksecrets.outputs.secretspresent == 'YES'
37+
if: steps.check_label.outputs.has_label_binaries == 'yes'
3538
uses: appleboy/[email protected]
3639
with:
3740
script: rm -rf /var/www/builds.jabref.org/www/pull/${{ github.event.pull_request.number }} || true
3841
host: build-upload.jabref.org
3942
port: 9922
4043
username: jrrsync
4144
key: ${{ secrets.buildJabRefPrivateKey }}
45+
- name: Get changed docker files
46+
# in line with dockerimages.yml -> lines 6 and 7
47+
id: changed-docker-files
48+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
49+
with:
50+
# Avoid using single or double quotes for multiline patterns
51+
files: |
52+
.github/workflows/dockerimages.yml
53+
Dockerfile.*
4254
- name: Remove Docker Tag
55+
if: steps.changed-docker-files.outputs.any_changed == 'true'
4356
# A separate action is needed to delete a tag - see https://github.com/orgs/community/discussions/26267
4457
uses: rafalkk/remove-dockertag-action@v1
4558
with:

.github/workflows/dockerimages.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
type=edge,branch=main
3939
type=ref,event=pr
4040
- name: Login to GitHub Container Registry
41-
if: github.repository == 'JabRef/jabref'
41+
if: >
42+
(github.event_name == 'push' && github.repository == 'JabRef/jabref') ||
43+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'JabRef/jabref')
4244
uses: docker/login-action@v3
4345
with:
4446
registry: ghcr.io
@@ -51,7 +53,11 @@ jobs:
5153
- name: Build and push
5254
uses: docker/build-push-action@v6
5355
with:
54-
push: ${{ github.repository == 'JabRef/jabref' }}
56+
push: >
57+
${{
58+
(github.event_name == 'push' && github.repository == 'JabRef/jabref') ||
59+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'JabRef/jabref')
60+
}}
5561
platforms: linux/amd64
5662
tags: ${{ steps.meta.outputs.tags }}
5763
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)