From 2a33061ae499f19082f497d731891368734c4d54 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 20:49:18 +0900 Subject: [PATCH 01/11] 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 From dcefd4f0cfa8b8a65f4257cd44d896bc08524d9e Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 20:49:54 +0900 Subject: [PATCH 02/11] CI/CD testing branch --- .forgejo/workflows/deploy.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 6a86efb..7c68b85 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - astra/ci jobs: deploy: From 2a08708c695654d26272c12f17549d7eb4a29f74 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 20:54:21 +0900 Subject: [PATCH 03/11] Replace npm-install action with just "npm install" --- .forgejo/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 7c68b85..d1cdd60 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-node@v3 - name: Install dependencies - uses: bahmutov/npm-install@v1 + run: npm install - name: Build project run: npm run build From 9ee49f9089084564237d4d66244218270cb5b12a Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 20:56:13 +0900 Subject: [PATCH 04/11] I have no idea what I am doing --- .forgejo/workflows/deploy.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index d1cdd60..483e969 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -17,9 +17,11 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 - + with: + node-version: '18' + cache: 'npm' - name: Install dependencies - run: npm install + run: npm ci - name: Build project run: npm run build From 3de4682c3449be490a571c05c9f24c746f313c32 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:02:43 +0900 Subject: [PATCH 05/11] I am deno --- .forgejo/workflows/deploy.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 483e969..fb38adb 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -16,12 +16,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' + uses: scientific-witchery/setup-deno@v2 + - name: Install dependencies - run: npm ci + run: deno install - name: Build project run: npm run build From 55056128889630f94d969dc04a84b714cec97786 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:06:27 +0900 Subject: [PATCH 06/11] Still no idea --- .forgejo/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index fb38adb..7a3ccb7 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Node - uses: scientific-witchery/setup-deno@v2 + uses: https://git.witchctaft.systems/scientific-witchery/setup-deno@v2 - name: Install dependencies run: deno install From 4f85fe2ef6137951980915509e657f139fb398a2 Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:07:11 +0900 Subject: [PATCH 07/11] Typo -_- --- .forgejo/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 7a3ccb7..b56a3a9 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Node - uses: https://git.witchctaft.systems/scientific-witchery/setup-deno@v2 + uses: https://git.witchcraft.systems/scientific-witchery/setup-deno@v2 - name: Install dependencies run: deno install From df18b3f97ffff1d39c8b6dc7eb0762322e02d4fb Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:09:14 +0900 Subject: [PATCH 08/11] Will that work? --- .forgejo/workflows/deploy.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index b56a3a9..a731af1 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -15,14 +15,14 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Setup Node - uses: https://git.witchcraft.systems/scientific-witchery/setup-deno@v2 + - name: Setup Deno + uses: https://github.com/denoland/setup-deno@v2 - name: Install dependencies run: deno install - name: Build project - run: npm run build + run: deno task build - name: Setup SCP run: | From a2a7f8fcc792fdd6b75db71a7e5f6c9f6be0354d Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:12:10 +0900 Subject: [PATCH 09/11] Am I wrong? --- .forgejo/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index a731af1..3a0601f 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Deno - uses: https://github.com/denoland/setup-deno@v2 + uses: https://github.com/denoland/setup-deno@v1 - name: Install dependencies run: deno install From 965753107e38db4734de039af6948e158fef9fda Mon Sep 17 00:00:00 2001 From: Astra Date: Sun, 20 Apr 2025 21:14:27 +0900 Subject: [PATCH 10/11] I am so lost --- .forgejo/workflows/deploy.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index 3a0601f..edc1f84 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -15,8 +15,13 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + - name: Setup Deno - uses: https://github.com/denoland/setup-deno@v1 + uses: https://github.com/denoland/setup-deno@v2 - name: Install dependencies run: deno install From d440f1c465b87ed61a699c7ca0bfb45795e1b062 Mon Sep 17 00:00:00 2001 From: Astra Date: Mon, 21 Apr 2025 14:25:56 +0900 Subject: [PATCH 11/11] Trying a different approach for deploying the thing --- .forgejo/workflows/deploy.yaml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml index edc1f84..c6a05d0 100644 --- a/.forgejo/workflows/deploy.yaml +++ b/.forgejo/workflows/deploy.yaml @@ -29,22 +29,30 @@ jobs: - name: Build project run: deno task build - - name: Setup SCP + - name: Setup SSH run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 - chmod -R go-rwx ~/.ssh + chmod 600 ~/.ssh/id_ed25519 + cat > ~/.ssh/config << EOF + Host deploy + HostName ${{ vars.SERVER_HOST }} + User ${{ vars.SERVER_USER }} + IdentityFile ~/.ssh/id_ed25519 + StrictHostKeyChecking accept-new + BatchMode yes + PasswordAuthentication no + PubkeyAuthentication yes + EOF + chmod 600 ~/.ssh/config 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 }}" + echo "Deploying to ${{ vars.SERVER_HOST }} as ${{ vars.SERVER_USER }} to /var/www/pds/${{ 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" + run: ssh -v deploy 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: Create folder if not exists + run: ssh deploy "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 + run: scp -r ./dist/* deploy:/var/www/pds/${{ github.ref_name }}