Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a4794e7273 | |||
| 04a282dd5e | |||
| 9145fabb2b | |||
| f98737906f | |||
| 0f17374002 |
+25
-45
@@ -30,12 +30,15 @@ jobs:
|
|||||||
- name: Build release archive
|
- name: Build release archive
|
||||||
run: pnpm build:tar
|
run: pnpm build:tar
|
||||||
|
|
||||||
- name: Upload build artifact
|
- name: Upload artifact to server
|
||||||
uses: maxsargentdev/gitea-upload-artifact@v4
|
uses: appleboy/scp-action@v0.1.7
|
||||||
with:
|
with:
|
||||||
name: dist-archive
|
host: ${{ vars.DEPLOY_HOST }}
|
||||||
path: dist.tar.gz
|
username: ${{ vars.DEPLOY_USER }}
|
||||||
retention-days: 1
|
port: ${{ vars.DEPLOY_PORT }}
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
source: "dist.tar.gz"
|
||||||
|
target: "/tmp/dist.tar.gz"
|
||||||
|
|
||||||
upload-release-asset:
|
upload-release-asset:
|
||||||
name: Upload to Gitea Release
|
name: Upload to Gitea Release
|
||||||
@@ -43,22 +46,25 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download build artifact
|
- name: Download artifact from server
|
||||||
uses: christopherHX/gitea-download-artifact@v4
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
name: dist-archive
|
host: ${{ vars.DEPLOY_HOST }}
|
||||||
|
username: ${{ vars.DEPLOY_USER }}
|
||||||
|
port: ${{ vars.DEPLOY_PORT }}
|
||||||
|
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
command: |
|
||||||
|
set -e
|
||||||
|
mkdir -p ~/.cache/gitea-artifacts
|
||||||
|
cp /tmp/dist.tar.gz ~/.cache/gitea-artifacts/
|
||||||
|
|
||||||
- name: Upload to Gitea Release
|
- name: Upload release asset
|
||||||
run: |
|
uses: https://gitea.com/actions/forgejo-release@v1
|
||||||
set -e
|
with:
|
||||||
RELEASE_ID=$(jq -r '.release.id' "$GITEA_EVENT_PATH")
|
direction: upload
|
||||||
URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/${RELEASE_ID}/assets?name=dist.tar.gz"
|
files: ~/.cache/gitea-artifacts/dist.tar.gz
|
||||||
curl -fsSL \
|
env:
|
||||||
-X POST \
|
FORGEJO_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/gzip" \
|
|
||||||
--data-binary "@dist.tar.gz" \
|
|
||||||
"${URL}"
|
|
||||||
|
|
||||||
deploy-to-server:
|
deploy-to-server:
|
||||||
name: Deploy to onixbyte.cn
|
name: Deploy to onixbyte.cn
|
||||||
@@ -66,32 +72,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download build artifact
|
|
||||||
uses: christopherHX/gitea-download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: dist-archive
|
|
||||||
|
|
||||||
- name: Upload archive to server
|
|
||||||
env:
|
|
||||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
|
||||||
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
|
||||||
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
|
|
||||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
SSH_DIR="${RUNNER_TEMP}/ssh"
|
|
||||||
mkdir -p "$SSH_DIR"
|
|
||||||
chmod 700 "$SSH_DIR"
|
|
||||||
printf '%s\n' "$DEPLOY_SSH_KEY" > "$SSH_DIR/key"
|
|
||||||
chmod 600 "$SSH_DIR/key"
|
|
||||||
scp -i "$SSH_DIR/key" \
|
|
||||||
-P "$DEPLOY_PORT" \
|
|
||||||
-o StrictHostKeyChecking=accept-new \
|
|
||||||
-o UserKnownHostsFile="$SSH_DIR/known_hosts" \
|
|
||||||
dist.tar.gz \
|
|
||||||
"${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/dist.tar.gz"
|
|
||||||
rm -rf "$SSH_DIR"
|
|
||||||
|
|
||||||
- name: Extract archive and deploy
|
- name: Extract archive and deploy
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
image: node:24.15-trixie-slim
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
rules:
|
||||||
|
- if: $CI_RELEASE_DESCRIPTION
|
||||||
|
script:
|
||||||
|
- corepack enable
|
||||||
|
- corepack prepare pnpm --activate
|
||||||
|
- pnpm install --frozen-lockfile
|
||||||
|
- pnpm build
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- dist/
|
||||||
|
expire_in: 7 days
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
rules:
|
||||||
|
- if: $CI_RELEASE_DESCRIPTION
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
script:
|
||||||
|
- apt-get update -qq && apt-get install -y -qq openssh-client rsync
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- echo "$SSH_PRIVATE_KEY_BASE64" | base64 -d > ~/.ssh/id_rsa
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||||
|
- rsync -avz --delete dist/ "${SSH_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|
||||||
Reference in New Issue
Block a user