ci: rewrite build workflow as single job with native scp
@@ -5,8 +5,8 @@ on:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build release archive
|
||||
build-deploy:
|
||||
name: Build, Release and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -30,32 +30,19 @@ jobs:
|
||||
- name: Build release archive
|
||||
run: pnpm build:tar
|
||||
|
||||
- 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/build-artifact/"
|
||||
- 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}"
|
||||
|
||||
- name: Move artifact to /tmp
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ vars.DEPLOY_HOST }}
|
||||
username: ${{ vars.DEPLOY_USER }}
|
||||
port: ${{ vars.DEPLOY_PORT }}
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
command: mv /tmp/build-artifact/dist.tar.gz /tmp/dist.tar.gz && rm -rf /tmp/build-artifact
|
||||
|
||||
upload-release-asset:
|
||||
name: Upload to Gitea Release
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download artifact from server
|
||||
- name: Upload archive to server
|
||||
env:
|
||||
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
|
||||
@@ -72,28 +59,10 @@ jobs:
|
||||
-P "$DEPLOY_PORT" \
|
||||
-o StrictHostKeyChecking=accept-new \
|
||||
-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"
|
||||
|
||||
- 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
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
|
||||