Skip to content

Commit 071c42d

Browse files
authored
Update build.yml
1 parent 9601fd9 commit 071c42d

File tree

1 file changed

+19
-42
lines changed

1 file changed

+19
-42
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,34 @@
1-
name: Build & Deploy
1+
name: Build & Publish Docker Image
22

33
on:
44
push:
5+
branches:
6+
- main
57
workflow_dispatch:
68

79
jobs:
8-
build:
10+
build-and-push:
911
runs-on: ubuntu-latest
10-
strategy:
11-
matrix:
12-
node-version: ['20']
13-
name: Build using Node v${{ matrix.node-version }}
1412
steps:
15-
- name: Checkout
13+
- name: Checkout repository
1614
uses: actions/checkout@v4
1715

18-
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v4
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@v3
2018
with:
21-
node-version: ${{ matrix.node-version }}
22-
cache: npm
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_PASSWORD }}
2321

24-
- name: Install dependencies
25-
run: npm install
26-
27-
- name: Build project
28-
run: npm run build
29-
env:
30-
CI: true
31-
32-
- name: Upload build artifacts
33-
uses: actions/upload-artifact@v4
34-
with:
35-
name: dist
36-
path: dist
37-
retention-days: 1 # نگهداری فایل‌ها برای ۱ روز
38-
39-
deploy:
40-
needs: build
41-
runs-on: ubuntu-latest
42-
steps:
43-
- name: Checkout
44-
uses: actions/checkout@v4
45-
46-
- name: Download build artifacts
47-
uses: actions/download-artifact@v4
22+
- name: Extract metadata for Docker
23+
id: meta
24+
uses: docker/metadata-action@v5
4825
with:
49-
name: dist
50-
path: dist
26+
images: pymmdrza/blockhub
5127

52-
- name: Deploy to GitHub Pages
53-
uses: peaceiris/actions-gh-pages@v4
28+
- name: Build and push Docker image
29+
uses: docker/build-push-action@v5
5430
with:
55-
github_token: ${{ secrets.GITHUB_TOKEN }}
56-
publish_dir: dist
57-
branch: gh-pages
31+
context: .
32+
push: true
33+
tags: pymmdrza/blockhub:latest
34+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)