Skip to content

Commit 84ce7b6

Browse files
authored
Merge pull request #45 from datastax/auto-docker-push
added GH action to auto push to docker hub
2 parents 937e005 + 577d40d commit 84ce7b6

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/docker-publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and publish to docker repo
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'src/**'
10+
- 'pom.xml'
11+
- 'Dockerfile'
12+
- 'LICENSE.md'
13+
tags:
14+
- 'v*.*.*'
15+
- 'v*.*.*-*'
16+
17+
jobs:
18+
build_and_publish:
19+
name: Build and publish docker image
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out source code
23+
uses: actions/checkout@v3
24+
# Setup metadata based on the commit/tag that will be used for tagging the image
25+
- name: Setup Docker meta
26+
id: meta
27+
uses: docker/metadata-action@v3
28+
with:
29+
images: |
30+
datastax/cassandra-data-migrator
31+
flavor: |
32+
latest=auto
33+
tags: |
34+
type=ref,event=branch
35+
type=semver,pattern={{version}}
36+
type=semver,pattern={{major}}.{{minor}}.x
37+
type=semver,pattern={{major}}.x
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v1
40+
- name: Login to DockerHub
41+
uses: docker/login-action@v1
42+
with:
43+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
44+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
45+
- name: Build and push
46+
id: docker_build
47+
uses: docker/build-push-action@v2
48+
with:
49+
file: Dockerfile
50+
context: .
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
platforms: linux/amd64
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and publish commit release to docker repo
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
build_and_publish:
7+
name: Build and publish docker image
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out source code
11+
uses: actions/checkout@v3
12+
# Setup metadata based on the commit/tag that will be used for tagging the image
13+
# Only build and publish a commit based tag
14+
- name: Setup Docker meta
15+
id: meta
16+
uses: docker/metadata-action@v3
17+
with:
18+
images: |
19+
datastax/cassandra-data-migrator
20+
flavor: |
21+
latest=false
22+
tags: |
23+
type=sha
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v1
26+
- name: Login to DockerHub
27+
uses: docker/login-action@v1
28+
with:
29+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
30+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
31+
- name: Build and push
32+
id: docker_build
33+
uses: docker/build-push-action@v2
34+
with:
35+
file: Dockerfile
36+
context: .
37+
push: true
38+
tags: ${{ steps.meta.outputs.tags }}
39+
platforms: linux/amd64

0 commit comments

Comments
 (0)