From ac5d0c510fee7f05047ef0e32d44232caddbcb37 Mon Sep 17 00:00:00 2001 From: Inggih Wicaksono Date: Tue, 23 Jun 2026 17:31:52 +0700 Subject: [PATCH] ci: add continuous deployment workflow --- .github/workflows/cd.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..00796af --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,23 @@ + +name: Continuous Deployment +on: + push: + branches: + - main +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Deploy ke EC2 via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + cd ~/notes-api-express + git checkout main # pastikan berada di branch yang benar + git pull origin main # tarik kode terbaru + npm ci # pasang dependensi + npm run migrate up # jalankan migrasi + pm2 reload notes-api # reload aplikasi tanpa downtime \ No newline at end of file