Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #111 from badging/CI/CD-fixes
Browse files Browse the repository at this point in the history
added firebase configs for live preview
  • Loading branch information
kaxada authored May 21, 2023
2 parents 710db23 + 6967587 commit 8465c03
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "event-badging"
}
}
50 changes: 38 additions & 12 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,78 @@
name: CI/CD Pipeline

on:
push:
branches:
- "*"
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [19.x]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run format
- run: npm run build
- run: npm install firebase-tools
- run: firebase deploy --token ${{ secrets.FIREBASE_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Format code
run: npm run format

- name: Build project
run: npm run build

- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
name: build
path: build

deploy:
deploy_firebase:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build
path: build

- name: Deploy new build to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_EVENT_BADGING }}"
projectId: event-badging
entryPoint: "/firebase.json"

deploy_remote_server:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- uses: actions/checkout@v3
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build
path: build

- name: remove old build
- name: Remove old build from remote server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DROPLET_IP_ADDRESS }}
Expand All @@ -56,7 +82,7 @@ jobs:
echo ${{ secrets.SSHPASSWORD }} | sudo -S rm -rf /var/www/badging.chaoss.community/*
mkdir -p /var/www/badging.chaoss.community/
- name: deploy new build
- name: Deploy new build to remote server
uses: garygrossgarten/github-action-scp@release
with:
host: ${{ secrets.DROPLET_IP_ADDRESS }}
Expand All @@ -65,7 +91,7 @@ jobs:
local: ${{ github.workspace }}/build
remote: "/var/www/badging.chaoss.community/"

- name: restart nginx
- name: Restart Nginx on remote server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DROPLET_IP_ADDRESS }}
Expand Down
12 changes: 12 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

0 comments on commit 8465c03

Please sign in to comment.