-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (66 loc) · 2.26 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Release Pipeline
on:
release:
types:
- published
jobs:
build-push-deploy-backend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push the Docker image
- name: Build and Push Docker Image
working-directory: ./backend
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
# Build the Docker image
docker build -t ghcr.io/ikapiar/backend:${VERSION} .
docker tag ghcr.io/ikapiar/backend:${VERSION} ghcr.io/ikapiar/backend:latest
# Push the Docker image
docker push ghcr.io/ikapiar/backend:${VERSION}
docker push ghcr.io/ikapiar/backend:latest
build-and-deploy-frontend:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Set up Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18 # Adjust based on your project requirements
# Install dependencies and build frontend
- name: Install and Build Frontend
working-directory: ./frontend
run: |
npm install
npm run build
# Deploy built static files using rsync
- name: Deploy Frontend to Server
env:
HOSTNAME: ${{ secrets.HOSTNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.KEY }}
USERNAME: ${{ secrets.USERNAME }}
run: |
# Save SSH key to a temporary file
echo "$KEY" > /tmp/deploy_key
chmod 600 /tmp/deploy_key
# Use rsync to deploy static files
rsync -avz -e "ssh -p $PORT -i /tmp/deploy_key -o StrictHostKeyChecking=no" ./frontend/out/ "$USERNAME@$HOSTNAME:/var/www/ikapiar"
# Clean up the temporary key
rm -f /tmp/deploy_key