Skip to content

Commit 20e2224

Browse files
committed
added docker ci
1 parent 5e29455 commit 20e2224

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Diff for: .github/workflows/dockerize.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
branches: ['main']
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- run: echo "Starting checkout and docker build & tag process by ${{ github.actor }}"
17+
- run: echo "JOB ID =====> ${{ github.run_id }} from branch ${{ github.ref }}"
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Login to Docker Hub
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
28+
- name: Extract branch name
29+
shell: bash
30+
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | sed 's/[^a-zA-Z0-9]/-/g')" >> $GITHUB_ENV
31+
32+
- name: Generate Docker metadata
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ secrets.DOCKER_USERNAME }}/gittrackr
37+
tags: |
38+
type=raw,value=${{ env.BRANCH_NAME }}-{{date 'YYYYMMDDHHmm'}}
39+
type=raw,value=${{ env.BRANCH_NAME }}-latest
40+
type=raw,value=latest,enable={{is_default_branch}}
41+
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: .
46+
push: true
47+
tags: ${{ steps.meta.outputs.tags }}
48+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)