1
1
name : Docker Image CI
2
2
on :
3
3
push :
4
- branches :
5
- - main
4
+ tags : ['v[0-9].[0-9]+.[0-9]+']
6
5
pull_request :
7
6
8
7
jobs :
@@ -12,34 +11,40 @@ jobs:
12
11
- name : Check out code
13
12
uses : actions/checkout@v3
14
13
- name : Build the Docker images
15
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
14
+ if : startsWith( github.ref, 'refs/tags')
16
15
run : |
17
- docker build --no-cache -t quay.io/krkn-chaos/krkn containers/
16
+ docker build --no-cache -t quay.io/krkn-chaos/krkn containers/ --build-arg TAG=${GITHUB_REF#refs/tags/}
18
17
docker tag quay.io/krkn-chaos/krkn quay.io/redhat-chaos/krkn
18
+ docker tag quay.io/krkn-chaos/krkn quay.io/redhat-chaos/krkn:${GITHUB_REF#refs/tags/}
19
+
19
20
- name : Test Build the Docker images
20
21
if : ${{ github.event_name == 'pull_request' }}
21
22
run : |
22
23
docker build --no-cache -t quay.io/krkn-chaos/krkn containers/ --build-arg PR_NUMBER=${{ github.event.pull_request.number }}
23
24
- name : Login in quay
24
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
25
+ if : startsWith( github.ref, 'refs/tags')
25
26
run : docker login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN}
26
27
env :
27
28
QUAY_USER : ${{ secrets.QUAY_USERNAME }}
28
29
QUAY_TOKEN : ${{ secrets.QUAY_PASSWORD }}
29
30
- name : Push the KrknChaos Docker images
30
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
31
- run : docker push quay.io/krkn-chaos/krkn
31
+ if : startsWith(github.ref, 'refs/tags')
32
+ run : |
33
+ docker push quay.io/krkn-chaos/krkn
34
+ docker push quay.io/krkn-chaos/krkn:${GITHUB_REF#refs/tags/}
32
35
- name : Login in to redhat-chaos quay
33
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
36
+ if : startsWith( github.ref, 'refs/tags/v')
34
37
run : docker login quay.io -u ${QUAY_USER} -p ${QUAY_TOKEN}
35
38
env :
36
39
QUAY_USER : ${{ secrets.QUAY_USER_1 }}
37
40
QUAY_TOKEN : ${{ secrets.QUAY_TOKEN_1 }}
38
41
- name : Push the RedHat Chaos Docker images
39
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
40
- run : docker push quay.io/redhat-chaos/krkn
42
+ if : startsWith(github.ref, 'refs/tags')
43
+ run : |
44
+ docker push quay.io/redhat-chaos/krkn
45
+ docker push quay.io/redhat-chaos/krkn:${GITHUB_REF#refs/tags/}
41
46
- name : Rebuild krkn-hub
42
- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
47
+ if : startsWith( github.ref, 'refs/tags')
43
48
uses : redhat-chaos/actions/krkn-hub@main
44
49
with :
45
50
QUAY_USER : ${{ secrets.QUAY_USERNAME }}
0 commit comments