From e0c901f511a21a3099a76fa1e030f6bb5d97043f Mon Sep 17 00:00:00 2001 From: FarhanMaulanaF Date: Fri, 16 Jun 2023 08:38:42 +0700 Subject: [PATCH 1/4] Add main.yml --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..85607fc9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +name: Test, Build, and Deploy | Modul 01 - Lab2.2 Senior Project + +on: + push: + branches: [main] + +jobs: + test-build: + runs-on: ubuntu-lastest + + strategy: + matrix: + node-version: [16.x] + + steps: + - uses: actions/checkout@v2 + - name: Testing Build pre-Deploy + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm i + - run: npm run build \ No newline at end of file From b4c140dc6b0f36163b016d81fecf34a40c36a3d1 Mon Sep 17 00:00:00 2001 From: FarhanMaulanaF Date: Fri, 16 Jun 2023 08:47:04 +0700 Subject: [PATCH 2/4] Fix typo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85607fc9..db805df6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ on: jobs: test-build: - runs-on: ubuntu-lastest + runs-on: ubuntu-latest strategy: matrix: From e2e0c30a7bbca7aa1fd18a7039f49ffc5f994741 Mon Sep 17 00:00:00 2001 From: Farhan Firmansyah <79140705+FarhanMaulanaF@users.noreply.github.com> Date: Fri, 16 Jun 2023 08:59:30 +0700 Subject: [PATCH 3/4] Update main.yml --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db805df6..b0a5c09f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,4 +20,46 @@ jobs: node-version: ${{ matrix.node-version }} cache: "npm" - run: npm i - - run: npm run build \ No newline at end of file + - 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/senpro-ssh-21 + echo "Cek folder project"; + [ ! -d "${HOME}/senpro/460544/modul02/senpro-github-action/" ] && + { + echo "Repository belum di-clone. Cloning..."; + mkdir -p ~/senpro/460544/modul02/; + cd ~/senpro/460544/modul02; + git clone git@github.com:FarhanMaulanaF/senpro-github-action.git; + cd ~/senpro/460544/modul02/senpro-github-action; + echo "Install Package dan Build Project"; + npm install; + npm run build; + } || + { + echo "Repository sudah ada. Building..."; + cd ~/senpro/460544/modul02/senpro-github-action; + git restore; + git restore .; + git pull origin main; + echo "Install Package dan Build Project"; + npm install; + npm run build; + } From 7606e43416f726fddf1162705c3b67e161a55e93 Mon Sep 17 00:00:00 2001 From: Farhan Firmansyah <79140705+FarhanMaulanaF@users.noreply.github.com> Date: Fri, 16 Jun 2023 09:11:51 +0700 Subject: [PATCH 4/4] Fix main.yml --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b0a5c09f..acc12daf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: node-version: [16.x] - + steps: - uses: actions/checkout@v2 - name: Testing Build pre-Deploy @@ -21,15 +21,15 @@ jobs: cache: "npm" - run: npm i - 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