Skip to content

Commit db1e3ba

Browse files
authored
Merge pull request #76 from tum-gis/feature/workflow-updates
Feature/workflow updates
2 parents 04f6896 + e49f4c9 commit db1e3ba

File tree

5 files changed

+70
-73
lines changed

5 files changed

+70
-73
lines changed
Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,36 @@
1-
name: Cleanup dev images of merged PRs
2-
1+
name: Cleanup Pull Request Images
32
on:
4-
schedule:
5-
- cron: "0 2 * * *" # Runs daily at 2 AM UTC
6-
workflow_dispatch: # Allows manual triggering
3+
pull_request:
4+
types: [closed]
5+
workflow_dispatch:
6+
inputs:
7+
pr-number:
8+
description: 'Pull Request Number'
9+
required: true
10+
default: '0'
711

812
env:
9-
IMAGE_NAME: ckan-sddi-dev
10-
IMAGE_OWNER: ${{ github.repository_owner }}
13+
PACKAGE_NAME: ckan-sddi-dev
1114

1215
jobs:
13-
cleanup-ghcr:
16+
ghcr-cleanup-image:
17+
if: github.event_name == 'pull_request'
18+
name: ghcr cleanup action
1419
runs-on: ubuntu-latest
1520
steps:
16-
- name: Checkout Repository
17-
uses: actions/checkout@v4
18-
19-
- name: Get Image Tags from GHCR
20-
run: |
21-
GHCR_API="https://ghcr.io/v2/$IMAGE_OWNER/$IMAGE_NAME/tags/list"
22-
TAGS=$(curl -s -H "Authorization: Bearer $(echo ${{ secrets.GITHUB_TOKEN }} | base64)" "$GHCR_API" | jq -r '.tags[]')
23-
echo "$TAGS" > tags_list.txt
24-
25-
- name: Identify Merged PRs
26-
run: |
27-
MAPPED_TAGS=()
28-
while read -r TAG; do
29-
if [[ $TAG =~ ^[a-zA-Z0-9]+-pr-(\d+)(?:-[a-f0-9]+)?$ ]]; then
30-
PR_NUMBER=${BASH_REMATCH[1]}
31-
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
32-
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")
33-
MERGED=$(echo "$RESPONSE" | jq -r '.merged')
34-
if [[ "$MERGED" == "true" ]]; then
35-
MAPPED_TAGS+=("$TAG")
36-
fi
37-
fi
38-
done < tags_list.txt
39-
printf "%s\n" "${MAPPED_TAGS[@]}" > delete_tags.txt
40-
echo "Images to be deleted:" && cat delete_tags.txt
21+
- name: Delete image
22+
uses: dataaxiom/ghcr-cleanup-action@v1
23+
with:
24+
delete-tags: "*pr-${{github.event.pull_request.number}}*"
25+
package: ${{ env.PACKAGE_NAME }}
4126

42-
- name: Delete Merged PR Images
43-
if: ${{ always() }}
44-
run: |
45-
if [ -s delete_tags.txt ]; then
46-
echo "Deleting the following images:" && cat delete_tags.txt
47-
while read -r TAG; do
48-
DIGEST=$(curl -s -H "Authorization: Bearer $(echo ${{ secrets.GITHUB_TOKEN }} | base64)" \
49-
-H "Accept: application/vnd.oci.image.manifest.v1+json" \
50-
"https://ghcr.io/v2/$IMAGE_OWNER/$IMAGE_NAME/manifests/$TAG" | jq -r '.config.digest')
51-
if [ "$DIGEST" != "null" ]; then
52-
GHCR_DELETE_URL="https://ghcr.io/v2/$IMAGE_OWNER/$IMAGE_NAME/manifests/$DIGEST"
53-
curl -X DELETE -H "Authorization: Bearer $(echo ${{ secrets.GITHUB_TOKEN }} | base64)" "$GHCR_DELETE_URL"
54-
fi
55-
done < delete_tags.txt
56-
else
57-
echo "No images to delete."
58-
fi
27+
ghcr-cleanup-image-manual:
28+
if: github.event_name == 'workflow_dispatch'
29+
name: ghcr cleanup action
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Delete image
33+
uses: dataaxiom/ghcr-cleanup-action@v1
34+
with:
35+
delete-tags: "*pr-${{ inputs.pr-number }}*"
36+
package: ${{ env.PACKAGE_NAME }}

.github/workflows/devel.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- sddi-base/**
88
- sddi/**
9+
workflow_dispatch:
910

1011
env:
1112
REGISTRY: ghcr.io
@@ -25,18 +26,18 @@ jobs:
2526

2627
steps:
2728
- name: Checkout repository
28-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
2930

3031
- name: Log in to the Github Container Registry
31-
uses: docker/login-action@v2
32+
uses: docker/login-action@v3
3233
with:
3334
registry: ${{ env.REGISTRY }}
3435
username: ${{ github.actor }}
3536
password: ${{ secrets.GITHUB_TOKEN }}
3637

3738
- name: Extract metadata (tags, labels) for devel docker image
3839
id: meta
39-
uses: docker/metadata-action@v4
40+
uses: docker/metadata-action@v5
4041
with:
4142
images: |
4243
${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
@@ -45,10 +46,11 @@ jobs:
4546
labels: |
4647
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
4748
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
48-
org.opencontainers.image.title=ckan-sddi-docker
49+
org.opencontainers.image.title=ckan-sddi-base-docker-devel
50+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
4951
5052
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}:devel
51-
uses: docker/build-push-action@v4
53+
uses: docker/build-push-action@v6
5254
with:
5355
context: ${{ matrix.context }}
5456
push: true
@@ -59,7 +61,7 @@ jobs:
5961
6062
- name: Extract metadata (tags, labels) for devel-debug docker image
6163
id: meta-debug
62-
uses: docker/metadata-action@v4
64+
uses: docker/metadata-action@v5
6365
with:
6466
images: |
6567
${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
@@ -68,10 +70,10 @@ jobs:
6870
labels: |
6971
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
7072
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
71-
org.opencontainers.image.title=ckan-sddi-docker
73+
org.opencontainers.image.title=ckan-sddi-base-docker-devel-debug
7274
7375
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}:devel-debug
74-
uses: docker/build-push-action@v4
76+
uses: docker/build-push-action@v6
7577
with:
7678
context: ${{ matrix.context }}
7779
file: ${{ matrix.context }}/Dockerfile.debug

.github/workflows/edge.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- sddi-base/**
88
- sddi/**
9+
workflow_dispatch:
910

1011
env:
1112
REGISTRY: ghcr.io
@@ -25,18 +26,18 @@ jobs:
2526

2627
steps:
2728
- name: Checkout repository
28-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
2930

3031
- name: Log in to the Github Container Registry
31-
uses: docker/login-action@v2
32+
uses: docker/login-action@v3
3233
with:
3334
registry: ${{ env.REGISTRY }}
3435
username: ${{ github.actor }}
3536
password: ${{ secrets.GITHUB_TOKEN }}
3637

3738
- name: Extract metadata (tags, labels) for docker image
3839
id: meta
39-
uses: docker/metadata-action@v4
40+
uses: docker/metadata-action@v5
4041
with:
4142
images: |
4243
${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
@@ -45,10 +46,11 @@ jobs:
4546
labels: |
4647
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
4748
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
48-
org.opencontainers.image.title=ckan-sddi-docker
49+
org.opencontainers.image.title=ckan-sddi-base-docker-edge
50+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
4951
5052
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
51-
uses: docker/build-push-action@v4
53+
uses: docker/build-push-action@v6
5254
with:
5355
context: ${{ matrix.context }}
5456
push: true
@@ -59,7 +61,7 @@ jobs:
5961
6062
- name: Extract metadata (tags, labels) for debug docker image
6163
id: meta-debug
62-
uses: docker/metadata-action@v4
64+
uses: docker/metadata-action@v5
6365
with:
6466
images: |
6567
${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
@@ -68,10 +70,11 @@ jobs:
6870
labels: |
6971
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
7072
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
71-
org.opencontainers.image.title=ckan-sddi-docker
73+
org.opencontainers.image.title=ckan-sddi-base-docker-edge-debug
74+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
7275
7376
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
74-
uses: docker/build-push-action@v4
77+
uses: docker/build-push-action@v6
7578
with:
7679
context: ${{ matrix.context }}
7780
file: ${{ matrix.context }}/Dockerfile.debug

.github/workflows/pull-request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
paths:
66
- sddi-base/**
77
- sddi/**
8+
workflow_dispatch:
9+
inputs:
10+
pr-number:
11+
description: 'Pull Request Number'
12+
required: true
13+
default: '0'
814

915
env:
1016
REGISTRY: ghcr.io
@@ -50,6 +56,7 @@ jobs:
5056
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
5157
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
5258
org.opencontainers.image.title=ckan-sddi-base-docker-dev
59+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
5360
-
5461
name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-sddi-dev:sddi-base-pr-${{github.event.number}}
5562
uses: docker/build-push-action@v6
@@ -79,6 +86,7 @@ jobs:
7986
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
8087
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
8188
org.opencontainers.image.title=ckan-sddi-base-docker-dev-debug
89+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
8290
-
8391
name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-sddi-dev:sddi-base-pr-${{github.event.number}}-debug
8492
uses: docker/build-push-action@v6
@@ -112,6 +120,7 @@ jobs:
112120
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
113121
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
114122
org.opencontainers.image.title=ckan-sddi-docker-dev
123+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
115124
-
116125
name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-sddi-dev:sddi-pr-${{github.event.number}}
117126
uses: docker/build-push-action@v6
@@ -142,6 +151,7 @@ jobs:
142151
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
143152
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
144153
org.opencontainers.image.title=ckan-sddi-docker-dev-debug
154+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
145155
-
146156
name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-sddi-dev:sddi-pr-${{github.event.number}}-debug
147157
uses: docker/build-push-action@v6

.github/workflows/release.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,33 @@ jobs:
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626

2727
- name: Log in to the Github Container Registry
28-
uses: docker/login-action@v2
28+
uses: docker/login-action@v3
2929
with:
3030
registry: ${{ env.REGISTRY }}
3131
username: ${{ github.actor }}
3232
password: ${{ secrets.GITHUB_TOKEN }}
3333

3434
- name: Extract metadata (tags, labels) for docker image
3535
id: meta
36-
uses: docker/metadata-action@v4
36+
uses: docker/metadata-action@v5
3737
with:
3838
images: |
3939
${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
4040
tags: |
4141
type=semver,pattern={{version}}
4242
type=semver,pattern={{major}}.{{minor}}
43+
type=semver,pattern={{major}}
4344
labels: |
4445
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
4546
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
4647
org.opencontainers.image.title=ckan-sddi-docker
48+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
4749
4850
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}
49-
uses: docker/build-push-action@v4
51+
uses: docker/build-push-action@v6
5052
with:
5153
context: ${{ matrix.context }}
5254
push: true
@@ -57,7 +59,7 @@ jobs:
5759
5860
- name: Extract metadata (tags, labels) for debug docker image
5961
id: meta-debug
60-
uses: docker/metadata-action@v4
62+
uses: docker/metadata-action@v5
6163
with:
6264
flavor:
6365
latest=true,suffix=-debug,onlatest=true
@@ -66,13 +68,15 @@ jobs:
6668
tags: |
6769
type=semver,pattern={{version}}
6870
type=semver,pattern={{major}}.{{minor}}
71+
type=semver,pattern={{major}}
6972
labels: |
7073
maintainer=Chair of Geoinformatics, Technical University of Munich (TUM)
7174
org.opencontainers.image.vendor=Chair of Geoinformatics, Technical University of Munich (TUM)
72-
org.opencontainers.image.title=ckan-sddi-docker
75+
org.opencontainers.image.title=ckan-sddi-docker-debug
76+
org.opencontainers.image.documentation=https://github.com/tum-gis/ckan-docker
7377
7478
- name: Build and publish ${{ env.REGISTRY }}/tum-gis/ckan-${{ matrix.context }}-debug
75-
uses: docker/build-push-action@v4
79+
uses: docker/build-push-action@v6
7680
with:
7781
context: ${{ matrix.context }}
7882
file: ${{ matrix.context }}/Dockerfile.debug

0 commit comments

Comments
 (0)