Skip to content

Commit

Permalink
Merge pull request #1 from Hoang-Nguyen-Huy/PBS-108-Deploy
Browse files Browse the repository at this point in the history
[PBS-108][HoangHN] feat: 🐳 cicd for fe project
  • Loading branch information
Hoang-Nguyen-Huy authored Nov 20, 2024
2 parents 1471bca + 3f0fad8 commit 8bf305a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
46 changes: 20 additions & 26 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,26 @@ jobs:
- 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: Create .env file
run: |
echo "VITE_API_ENDPOINT=${{ secrets.VITE_API_ENDPOINT }}" >> .env
echo "VITE_URL=${{ secrets.VITE_URL }}" >> .env
echo "VITE_GOOGLE_CLIENT_ID=${{ secrets.VITE_GOOGLE_CLIENT_ID }}" >> .env
echo "VITE_GOOGLE_AUTHORIZED_REDIRECT_URI=${{ secrets.VITE_GOOGLE_AUTHORIZED_REDIRECT_URI }}" >> .env
echo "VITE_CLOUDINARY_CLOUD_NAME=${{ secrets.VITE_CLOUDINARY_CLOUD_NAME }}" >> .env
echo "VITE_CLOUDINARY_UPLOAD_PRESET=${{ secrets.VITE_CLOUDINARY_UPLOAD_PRESET }}" >> .env
echo "VITE_VNPAY_RETURN_URL=${{ secrets.VITE_VNPAY_RETURN_URL }}" >> .env
echo "VITE_VNPAY_RETURN_URL_AMENITY=${{ secrets.VITE_VNPAY_RETURN_URL_AMENITY }}" >> .env
echo "VITE_VNPAY_RETURN_ADMIN_URL=${{ secrets.VITE_VNPAY_RETURN_ADMIN_URL }}" >> .env
echo "VITE_VNPAY_RETURN_STAFF_AMENITY_URL=${{ secrets.VITE_VNPAY_RETURN_STAFF_AMENITY_URL }}" >> .env
echo "VITE_SOCKET_URL=${{ secrets.VITE_SOCKET_URL }}" >> .env
echo "VITE_API_KEY=${{ secrets.VITE_API_KEY }}" >> .env
echo "VITE_AUTH_DOMAIN=${{ secrets.VITE_AUTH_DOMAIN }}" >> .env
echo "VITE_PROJECT_ID=${{ secrets.VITE_PROJECT_ID }}" >> .env
echo "VITE_STORAGE_BUCKET=${{ secrets.VITE_STORAGE_BUCKET }}" >> .env
echo "VITE_MESSAGING_SENDER_ID=${{ secrets.VITE_MESSAGING_SENDER_ID }}" >> .env
echo "VITE_APP_ID=${{ secrets.VITE_APP_ID }}" >> .env
echo "VITE_MEASUREMENT_ID=${{ secrets.VITE_MEASUREMENT_ID }}" >> .env
- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
COPY .env .env
RUN npm run build

FROM nginx:alpine
Expand Down

0 comments on commit 8bf305a

Please sign in to comment.