Skip to content

Commit 152ec95

Browse files
committed
feat: added Docker image autobuild
1 parent 4c14380 commit 152ec95

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/docker.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docker
2+
3+
# This will run when:
4+
# - when new code is pushed to main/develop to push the tags
5+
# latest and develop
6+
# - when a pull request is created and updated to make sure the
7+
# Dockerfile is still valid.
8+
# To be able to push to dockerhub, this execpts the following
9+
# secrets to be set in the project:
10+
# - DOCKERHUB_USERNAME : username that can push to the org
11+
# - DOCKERHUB_PASSWORD : password asscoaited with the username
12+
on:
13+
push:
14+
branches:
15+
- main
16+
- develop
17+
18+
pull_request:
19+
20+
# Trigger the workflow on release activity
21+
release:
22+
# Only use the types keyword to narrow down the activity types that will trigger your workflow.
23+
types:
24+
- published
25+
- edited
26+
- created
27+
28+
# Certain actions will only run when this is the main repo.
29+
env:
30+
MAIN_REPO: nds-org/custom-errors
31+
DOCKERHUB_ORG: ndslabs
32+
33+
jobs:
34+
docker:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v2
39+
40+
- uses: actions/checkout@v3
41+
42+
- name: Docker meta
43+
id: meta
44+
uses: docker/metadata-action@v4
45+
with:
46+
images: |
47+
ndslabs/custom-errors
48+
tags: |
49+
# set latest tag for default branch
50+
type=raw,value=latest,enable={{is_default_branch}}
51+
type=ref,event=branch
52+
type=ref,event=pr
53+
type=ref,event=tag
54+
type=semver,pattern={{version}}
55+
type=semver,pattern={{major}}.{{minor}}
56+
57+
- name: Login to DockerHub
58+
uses: docker/login-action@v2
59+
with:
60+
username: ${{ secrets.DOCKERHUB_USERNAME }}
61+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
62+
63+
64+
- name: Build and push
65+
uses: docker/build-push-action@v3
66+
with:
67+
context: .
68+
platforms: linux/amd64,linux/arm64
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)