From 2a33061ae499f19082f497d731891368734c4d54 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 20:49:18 +0900 Subject: [PATCH] CI/CD --- .forgejo/workflows/deploy.yaml | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .forgejo/workflows/deploy.yaml diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml new file mode 100644 index 0000000..6a86efb --- /dev/null +++ b/.forgejo/workflows/deploy.yaml @@ -0,0 +1,44 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v3 + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + + - name: Build project + run: npm run build + + - name: Setup SCP + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 + chmod -R go-rwx ~/.ssh + ssh-keyscan -H ${{ vars.SERVER_HOST }} >> ~/.ssh/known_hosts + echo "Deploying to ${{ vars.SERVER_HOST }} as ${{ vars.SERVER_USER }} to /home/common/www/${{ github.ref_name }}" + + - name: Debug SSH Connection + run: ssh -v -o PasswordAuthentication=no -i ~/.ssh/id_ed25519 ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} echo "SSH Connection Successful" + + - name: create folder if not exists + run: | + ssh -i ~/.ssh/id_ed25519 ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "mkdir -p /var/www/pds/${{ github.ref_name }}" + + - name: Deploy via SCP + run: | + scp -i ~/.ssh/id_ed25519 -rv ./dist/* ${{ vars.SERVER_USER }}@\[${{ vars.SERVER_HOST }}\]:/var/www/pds/${{ github.ref_name }} + \ No newline at end of file