From 20e26fff6f0503ca61e8daf8d8c1afa9394795e9 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Tue, 2 Jul 2024 00:43:30 +0300 Subject: [PATCH] build: add deploy to server --- .gitea/workflows/deploy.yaml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..daffe04 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,44 @@ +name: Build and Deploy Angular App + +on: + pull_request: + push: + branches: + [master, 'release/*'] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Build Angular app + run: ng build + + - name: Start ssh-agent + id: ssh-agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-passphrase: ${{ secrets.SSH_PASSPHRASE }} + + - name: Deploy to Server + env: + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + TARGET_DIR: ${{ secrets.TARGET_DIR }} + run: | + mkdir -p ~/.ssh + ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts + scp -r ./dist/frontend/* $SSH_USER@$SSH_HOST:$TARGET_DIR + ssh $SSH_USER@$SSH_HOST "sudo chown -R www-data:www-data $TARGET_DIR"