Skip to content

Commit 42da631

Browse files
committed
Change: Update creating tags for container images
Use new scheme for container image tags.
1 parent 1728da7 commit 42da631

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/container.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Container Image Builds
22

33
on:
44
push:
5-
branches: [ main, stable, oldstable ]
5+
branches: [main, stable, oldstable]
66
tags: ["v*"]
77
pull_request:
8-
branches: [ main, stable, oldstable ]
8+
branches: [main, stable, oldstable]
99
workflow_dispatch:
1010

1111
jobs:
@@ -24,17 +24,20 @@ jobs:
2424
labels: |
2525
org.opencontainers.image.vendor=Greenbone
2626
org.opencontainers.image.base.name=greenbone/openvas-scanner
27-
flavor: latest=false # no latest container tag for git tags
27+
flavor: latest=false # no auto latest container tag for git tags
2828
tags: |
29-
# create container tag for git tags
30-
type=ref,event=tag
29+
# use container tag for git tags
30+
type=match,pattern=v(.*),group=1
31+
# use latest for latest tag from stable branch
32+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v22.4') }}
33+
# use stable for latest 22.4 tag
34+
type=raw,value=stable,enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v22.4') }}
35+
# use edge for default branch
36+
type=edge
37+
# use branch-sha otherwise for pushes to branches other then main (will not be uploaded)
38+
type=raw,value={{branch}}-{{sha}},enable=${{ github.ref_type == 'branch' && github.event_name == 'push' && github.ref_name != 'main' }}
39+
# use pr-$PR_ID for pull requests (will not be uploaded)
3140
type=ref,event=pr
32-
# use latest for stable branch
33-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
34-
type=raw,value=stable,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
35-
type=raw,value=oldstable,enable=${{ github.ref == format('refs/heads/{0}', 'oldstable') }}
36-
# use unstable for main branch
37-
type=raw,value=unstable,enable={{is_default_branch}}
3841
- name: Login to GitHub Container Registry
3942
if: github.event_name != 'pull_request'
4043
uses: docker/login-action@v2
@@ -49,7 +52,7 @@ jobs:
4952
uses: docker/build-push-action@v3
5053
with:
5154
context: .
52-
push: ${{ github.event_name != 'pull_request' }}
55+
push: ${{ github.event_name != 'pull_request' && (github.ref_type == 'tag' || github.ref_name == 'main') }}
5356
platforms: linux/amd64,linux/arm64
5457
file: .docker/prod.Dockerfile
5558
tags: ${{ steps.meta.outputs.tags }}

0 commit comments

Comments
 (0)