Skip to content

[PBS-108][HoangHN] feat: 🐳 cicd for fe project #2

[PBS-108][HoangHN] feat: 🐳 cicd for fe project

[PBS-108][HoangHN] feat: 🐳 cicd for fe project #2

Workflow file for this run

name: POD Booking System Client CICD
on:
push:
branches: ['main', 'develop']
pull_request:
branches: ['main', 'develop']
jobs:
build:
name: Build and analyze
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Build project
run: npm run build
env:
VITE_API_ENDPOINT: ${{ secrets.VITE_API_ENDPOINT }}
VITE_URL: ${{ secrets.VITE_URL }}
VITE_GOOGLE_CLIENT_ID: ${{ secrets.VITE_GOOGLE_CLIENT_ID }}
VITE_GOOGLE_AUTHORIZED_REDIRECT_URI: ${{ secrets.VITE_GOOGLE_AUTHORIZED_REDIRECT_URI }}
VITE_CLOUDINARY_CLOUD_NAME: ${{ secrets.VITE_CLOUDINARY_CLOUD_NAME }}
VITE_CLOUDINARY_UPLOAD_PRESET: ${{ secrets.VITE_CLOUDINARY_UPLOAD_PRESET }}
VITE_VNPAY_RETURN_URL: ${{ secrets.VITE_VNPAY_RETURN_URL }}
VITE_VNPAY_RETURN_URL_AMENITY: ${{ secrets.VITE_VNPAY_RETURN_URL_AMENITY }}
VITE_VNPAY_RETURN_ADMIN_URL: ${{ secrets.VITE_VNPAY_RETURN_ADMIN_URL }}
VITE_VNPAY_RETURN_STAFF_AMENITY_URL: ${{ secrets.VITE_VNPAY_RETURN_STAFF_AMENITY_URL }}
VITE_SOCKET_URL: ${{ secrets.VITE_SOCKET_URL }}
VITE_API_KEY: ${{ secrets.VITE_API_KEY }}
VITE_AUTH_DOMAIN: ${{ secrets.VITE_AUTH_DOMAIN }}
VITE_PROJECT_ID: ${{ secrets.VITE_PROJECT_ID }}
VITE_STORAGE_BUCKET: ${{ secrets.VITE_STORAGE_BUCKET }}
VITE_MESSAGING_SENDER_ID: ${{ secrets.VITE_MESSAGING_SENDER_ID }}
VITE_APP_ID: ${{ secrets.VITE_APP_ID }}
VITE_MEASUREMENT_ID: ${{ secrets.VITE_MEASUREMENT_ID }}
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: production-files
path: ./dist
deploy:
name: Deploy to Server
runs-on: ubuntu-22.04
needs: build # Job deploy depend on job build
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and tag Docker image
run: |
docker build -t hoanghuynguyen/pod-booking-system-client:latest .
- name: Push Docker image to Docker Hub
run: |
docker push hoanghuynguyen/pod-booking-system-client:latest
- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd swp
docker pull hoanghuynguyen/pod-booking-system-client:latest
docker compose up -d
# # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6