Skip to content

Commit c3ea5e7

Browse files
committed
chore: add pipeline
1 parent 5f9cbba commit c3ea5e7

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
branches:
10+
- master
11+
12+
env:
13+
DOCKER_IMAGE: localstack-web
14+
REGISTRY: docker.io
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '18'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run linter
34+
run: npm run lint
35+
36+
- name: Build application
37+
run: npm run build
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Log in to DockerHub
43+
if: github.event_name != 'pull_request'
44+
uses: docker/login-action@v3
45+
with:
46+
username: ${{ secrets.DOCKERHUB_USERNAME }}
47+
password: ${{ secrets.DOCKERHUB_TOKEN }}
48+
49+
- name: Extract metadata
50+
id: meta
51+
uses: docker/metadata-action@v5
52+
with:
53+
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKER_IMAGE }}
54+
tags: |
55+
type=ref,event=branch
56+
type=ref,event=pr
57+
type=semver,pattern={{version}}
58+
type=semver,pattern={{major}}.{{minor}}
59+
type=semver,pattern={{major}}
60+
type=raw,value=latest,enable={{is_default_branch}}
61+
62+
- name: Build and push Docker image
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
file: ./Dockerfile
67+
push: ${{ github.event_name != 'pull_request' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max
72+
platforms: linux/amd64,linux/arm64
73+
74+
- name: Image digest
75+
if: github.event_name != 'pull_request'
76+
run: echo ${{ steps.build-push.outputs.digest }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ dist-ssr
2929
.env.development.local
3030
.env.test.local
3131
.env.production.local
32+
33+
# Docker
34+
.dockerignore
35+
docker-compose.override.yml

0 commit comments

Comments
 (0)