Skip to content

Commit 4e8f528

Browse files
committed
feat: add GitHub Actions workflow for building and pushing Docker images
1 parent fcbc868 commit 4e8f528

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
IMAGE_NAME: bysages/lens
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Log in to Docker Hub
30+
if: github.event_name != 'pull_request'
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ secrets.DOCKER_USERNAME }}
34+
password: ${{ secrets.DOCKER_PASSWORD }}
35+
36+
# create a unique tag for each build for debugging
37+
- name: Set Docker tag
38+
id: date
39+
run: echo "date_stamp=$(date +%s)" >> "$GITHUB_OUTPUT"
40+
41+
- name: Build and push Docker images
42+
uses: iloveitaly/github-action-nixpacks@main
43+
with:
44+
push: ${{ github.event_name != 'pull_request' }}
45+
tags: |
46+
${{ env.IMAGE_NAME }}:latest
47+
${{ env.IMAGE_NAME }}:${{ steps.date.outputs.date_stamp }}
48+
${{ env.IMAGE_NAME }}:${{ github.sha }}

0 commit comments

Comments
 (0)