Skip to content

Commit e78c429

Browse files
authored
prepare workflow for tags (#6)
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
1 parent 633df3e commit e78c429

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

.github/workflows/publish_image.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
name: Publish Image
33

44
concurrency:
5-
group: ${{ github.head_ref || github.run_id }}
6-
cancel-in-progress: true
5+
group: ${{ github.head_ref || github.run_id }}
6+
cancel-in-progress: true
77

88
on:
9+
release:
10+
types: [published]
911
workflow_dispatch:
1012

13+
env:
14+
image: ghcr.io/nilashishc/ansible-creator-service
15+
1116
jobs:
1217
build-test:
1318
runs-on: ubuntu-latest
@@ -24,6 +29,15 @@ jobs:
2429
password: ${{ secrets.GITHUB_TOKEN }}
2530

2631
- name: Build the container image for ansible-creator-service and publish it
32+
if: github.event_name == 'workflow_dispatch'
33+
run: |
34+
docker build -f Containerfile -t ${{ env.image }}:latest .
35+
36+
- name: Build the container image for ansible-creator-service and publish it (when tagged)
37+
if: github.event_name == 'release'
38+
run: |
39+
docker build -f Containerfile -t ${{ env.image }}:latest -t ${{ env.image }}:${{ github.ref_name }} .
40+
41+
- name: Push image with all tags
2742
run: |
28-
docker build -f Containerfile -t ghcr.io/nilashishc/ansible-creator-service:latest .
29-
docker push ghcr.io/nilashishc/ansible-creator-service:latest
43+
docker push ${{ env.image }} --all-tags

0 commit comments

Comments
 (0)