Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test, Build, and Deploy | Modul 01 - Lab2.2 Senior Project

on:
push:
branches: [main]

jobs:
test-build:
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v3

- name: Testing Build pre-Deploy
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- run: npm ci
- run: npm run build

deploy:
needs: test-build
runs-on: ubuntu-latest

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

steps:
- name: Build app on VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/ssh-praktikan23
echo "Cek folder project"
if [ ! -d "$HOME/senpro/515523/modul02/senpro-github-action/" ]; then
echo "Repository belum di-clone. Cloning..."
mkdir -p ~/senpro/515523/modul02
cd ~/senpro/515523/modul02
git clone https://github.com/fuykaa/senpro-github-action.git
cd ~/senpro/515523/modul02/senpro-github-action
echo "Install Package dan Build Project"
npm install
npm run build
else
echo "Repository sudah ada. Building..."
cd ~/senpro/515523/modul02/senpro-github-action
git restore .
git pull origin main
echo "Install Package dan Build Project"
npm install
npm run build
fi