Skip to content

Commit

Permalink
Case 2: Jobs untuk Terhubung ke VM
Browse files Browse the repository at this point in the history
  • Loading branch information
anggito-m committed Feb 14, 2025
1 parent 1ec6fa9 commit 332b586
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,44 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm i
- run: npm run build
- 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/ << NAMA_KEY_DARI_ASPRAK>>
echo "Cek folder project";
[ ! -d "${HOME}/senpro/<< NIU>>/modul02/senpro-github-action/" ] &&
{
echo "Repository belum di-clone. Cloning ... ";
mkdir -p ~/senpro/ << NIU>>/modul02;
cd ~/senpro/ << NIU>>/modul02;
git clone << LINK_REPOSITORY_FORK>>;
cd ~/senpro/ << NIU>>/modul02/senpro-github-action;
echo "Install Package dan Build Project";
npm install;
npm run build;
} ||
{
echo "Repository sudah ada. Building ... ";
cd ~/senpro/ << NIU>>/modul02/senpro-github-action;
git restore .;
git pull origin main;
echo "Install Package dan Build Project";
npm install;
npm run build;
}

0 comments on commit 332b586

Please sign in to comment.