Skip to content

Commit

Permalink
feat: main deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
incredible-phoenix246 committed Jan 28, 2025
1 parent 344a533 commit 7b14131
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 51 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "22"

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install dependencies
run: pnpm install
Expand All @@ -29,13 +27,11 @@ jobs:
run: pnpm build

- name: Archive production artifacts
run: tar -czf boilerplate.tar.gz .next public
run: tar -czf boilerplate.tar.gz .next

- name: Upload production artifacts
uses: actions/upload-artifact@v3
with:
name: boilerplate-build
path: boilerplate.tar.gz
- name: Copy Artifacts to server
run: |
sshpass -p $PASSWORD scp -o StrictHostKeyChecking=no boilerplate.tar.gz $USERNAME@$HOST:~/build-artifacts
- name: Delete zip file
run: rm -f boilerplate.tar.gz
58 changes: 17 additions & 41 deletions .github/workflows/production-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,27 @@ on:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main'}} && ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: hng12

environment:
name: "production"
url: ${{ vars.URL }}

steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
name: boilerplate-build
path: .
- name: Checkout Repository
uses: actions/checkout@v4

- name: Decode and create .env file
run: |
echo ${{ secrets.ENV_BASE64 }} | base64 -d > .env
- name: Copy to server
uses: appleboy/scp-action@master
- name: Set up Node.js
uses: actions/setup-node@v4
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: ".env,boilerplate.tar.gz"
target: "~/hng_boilerplate_nextjs/prod"

- name: Delete zip file
run: rm -f boilerplate.tar.gz
node-version: '22'

- name: Deploy on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
script: |
cd ~/hng_boilerplate_nextjs/prod
git add .
git stash
git reset --hard
git pull
tar -xzf boilerplate.tar.gz
rm -f boilerplate.tar.gz
pnpm install
pm2 restart boilerplate_fe_prod --update-env
- name: Deploy Main
run: |
cd ~/boilerplate/main
git reset --hard
git pull
cp ~/build-artifacts/boilerplate.tar.gz .
tar --overwrite -xzf boilerplate.tar.gz
rm -f boilerplate.tar.gz
pm2 stop boilerplate_main
pnpm install
pm2 restart boilerplate_main --update-env
2 changes: 2 additions & 0 deletions public/images/blogPage/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
export { default as blogCard1 } from '../../blogPage/blogCard1.png'
export { default as blogCard3 } from '../../blogPage/blogCard3.png'
export { default as blogCard2 } from '../../blogPage/blogCard2.png'
Expand Down

0 comments on commit 7b14131

Please sign in to comment.