From a5d6b460dd3c4d014608a30ef4402e576c3e8c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarik=20Dedi=C4=87?= Date: Sun, 8 Sep 2024 12:27:20 +0200 Subject: [PATCH] Update yaml file for deployment --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a73737d..0bbdfac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: CI/CD Pipeline on: push: branches: - - main + - main # Trigger deployment only on push to main pull_request: branches: - - main + - main # Run build checks on PRs but don't deploy jobs: build: @@ -24,36 +24,42 @@ jobs: - name: Install dependencies run: npm install + # Optional: Uncomment if you want to run tests # - name: Run tests # run: npm test -- --watch=false --browsers=ChromeHeadless - name: Build project run: npm run build - - name: upload artifact + - name: Upload artifact uses: actions/upload-artifact@v4 with: name: angular-build path: "./dist/smetovi/" deploy: + # Deploy only when a push is made directly to the main branch + if: github.ref == 'refs/heads/main' # Ensure deployment happens only on push to main needs: build runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v3 - - name: download artifact + + - name: Download artifact uses: actions/download-artifact@v4 with: name: angular-build path: "./dist/smetovi/" + - name: Deploy to cPanel hosting via FTP uses: SamKirkland/FTP-Deploy-Action@4.3.0 with: server: ${{ secrets.FTP_SERVER }} username: ${{ secrets.FTP_USERNAME }} password: ${{ secrets.FTP_PASSWORD }} - local-dir: ./dist/smetovi/ # Adjust this to match your project name + local-dir: ./dist/smetovi/ # Adjust this to match your project build output server-dir: /public_html/ # Adjust this to your target directory on the server port: ${{ secrets.FTP_PORT }} - log-level: verbose \ No newline at end of file + log-level: verbose