Skip to content

Commit

Permalink
Merge pull request nguyenhcp2004#243 from nguyenhcp2004/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Hoang-Nguyen-Huy authored Nov 20, 2024
2 parents c98d7e1 + a54c25a commit 1471bca
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }}
VITE_API_BASE_URL: ${{ secrets.API_BASE_URL }}

- 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

0 comments on commit 1471bca

Please sign in to comment.