Compare commits
3 Commits
main
..
1.4.0-dev.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
fbf87fa810
|
|||
|
66cb747e34
|
|||
|
fe2f920f4d
|
@@ -30,24 +30,12 @@ jobs:
|
|||||||
- name: Build release archive
|
- name: Build release archive
|
||||||
run: pnpm build:tar
|
run: pnpm build:tar
|
||||||
|
|
||||||
- name: Clean up previous build artifacts on server
|
- name: Upload build artifact
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: maxsargentdev/gitea-upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
host: ${{ vars.DEPLOY_HOST }}
|
name: dist-archive
|
||||||
username: ${{ vars.DEPLOY_USER }}
|
path: dist.tar.gz
|
||||||
port: ${{ vars.DEPLOY_PORT }}
|
retention-days: 1
|
||||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
command: rm -f /tmp/dist.tar.gz /tmp/*.tar.gz
|
|
||||||
|
|
||||||
- name: Upload artifact to server
|
|
||||||
uses: appleboy/scp-action@v0.1.7
|
|
||||||
with:
|
|
||||||
host: ${{ vars.DEPLOY_HOST }}
|
|
||||||
username: ${{ vars.DEPLOY_USER }}
|
|
||||||
port: ${{ vars.DEPLOY_PORT }}
|
|
||||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
||||||
source: "dist.tar.gz"
|
|
||||||
target: "/tmp/"
|
|
||||||
|
|
||||||
upload-release-asset:
|
upload-release-asset:
|
||||||
name: Upload to Gitea Release
|
name: Upload to Gitea Release
|
||||||
@@ -55,7 +43,35 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download artifact from server
|
- name: Download build artifact
|
||||||
|
uses: christopherHX/gitea-download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: dist-archive
|
||||||
|
|
||||||
|
- name: Upload to Gitea Release
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
RELEASE_ID=$(jq -r '.release.id' "$GITEA_EVENT_PATH")
|
||||||
|
URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/${RELEASE_ID}/assets?name=dist.tar.gz"
|
||||||
|
curl -fsSL \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/gzip" \
|
||||||
|
--data-binary "@dist.tar.gz" \
|
||||||
|
"${URL}"
|
||||||
|
|
||||||
|
deploy-to-server:
|
||||||
|
name: Deploy to onixbyte.cn
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download build artifact
|
||||||
|
uses: christopherHX/gitea-download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: dist-archive
|
||||||
|
|
||||||
|
- name: Upload archive to server
|
||||||
env:
|
env:
|
||||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||||
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
||||||
@@ -72,28 +88,10 @@ jobs:
|
|||||||
-P "$DEPLOY_PORT" \
|
-P "$DEPLOY_PORT" \
|
||||||
-o StrictHostKeyChecking=accept-new \
|
-o StrictHostKeyChecking=accept-new \
|
||||||
-o UserKnownHostsFile="$SSH_DIR/known_hosts" \
|
-o UserKnownHostsFile="$SSH_DIR/known_hosts" \
|
||||||
"${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/dist.tar.gz" \
|
dist.tar.gz \
|
||||||
./dist.tar.gz
|
"${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/dist.tar.gz"
|
||||||
rm -rf "$SSH_DIR"
|
rm -rf "$SSH_DIR"
|
||||||
|
|
||||||
- name: Upload release asset via Gitea API
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
RELEASE_ID=$(jq -r '.release.id' "$GITEA_EVENT_PATH")
|
|
||||||
URL="${GITEA_SERVER_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/${RELEASE_ID}/assets?name=dist.tar.gz"
|
|
||||||
curl -fsSL \
|
|
||||||
-X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/gzip" \
|
|
||||||
--data-binary "@dist.tar.gz" \
|
|
||||||
"${URL}"
|
|
||||||
|
|
||||||
deploy-to-server:
|
|
||||||
name: Deploy to onixbyte.cn
|
|
||||||
needs: [build, upload-release-asset]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- 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:
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
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}"
|
|
||||||