Skip to content

Commit 6765977

Browse files
committed
Add GitHub Action workflow for tags
1 parent 0dbf1c2 commit 6765977

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI to Docker Hub
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the master branch
6+
push:
7+
tags:
8+
- "*.*.*"
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
jobs:
15+
# This workflow contains a single job called "build"
16+
build:
17+
# The type of runner that the job will run on
18+
runs-on: ubuntu-latest
19+
20+
# Steps represent a sequence of tasks that will be executed as part of the job
21+
steps:
22+
23+
- name: Check Out Repo
24+
uses: actions/checkout@v2
25+
26+
- name: Docker meta
27+
id: meta
28+
uses: docker/metadata-action@v3
29+
with:
30+
# list of Docker images to use as base name for tags
31+
images: |
32+
kommonitor/processes-api
33+
# generate Docker tags based on the following events/attributes
34+
tags: |
35+
type=ref,event=branch
36+
type=ref,event=pr
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
40+
- name: Login to Docker Hub
41+
uses: docker/login-action@v1
42+
with:
43+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
44+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
45+
46+
- name: Set up Docker Buildx
47+
id: buildx
48+
uses: docker/setup-buildx-action@v1
49+
50+
- name: Build and push
51+
id: docker_build
52+
uses: docker/build-push-action@v2
53+
with:
54+
context: ./
55+
file: ./Dockerfile
56+
builder: ${{ steps.buildx.outputs.name }}
57+
push: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
61+
- name: Image digest
62+
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)