diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..a49e604 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,95 @@ +name: Build and Deploy + +on: + release: + types: [created] + +jobs: + build: + name: Build release archive + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 11 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build release archive + run: pnpm build:tar + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: dist-archive + path: dist.tar.gz + retention-days: 1 + + upload-release-asset: + name: Upload to Gitea Release + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: dist-archive + + - name: Upload release asset + uses: https://gitea.com/actions/forgejo-release@v1 + with: + direction: upload + files: dist.tar.gz + env: + FORGEJO_TOKEN: ${{ secrets.GITEA_TOKEN }} + + deploy-to-server: + name: Deploy to onixbyte.cn + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: dist-archive + + - name: Upload archive 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/" + + - name: Extract archive and set ownership + 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 }} + script_stop: true + script: | + set -e + DEPLOY_PATH="${{ vars.DEPLOY_PATH }}" + mkdir -p "$DEPLOY_PATH" + rm -rf "$DEPLOY_PATH"/* + tar -xzf /tmp/dist.tar.gz -C "$DEPLOY_PATH" --strip-components=1 + chown -R caddy:caddy "$DEPLOY_PATH" + rm -f /tmp/dist.tar.gz diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 9a810e3..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,27 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - -version: 2 -updates: - - package-ecosystem: "npm" - directory: "/" - schedule: - interval: "weekly" - commit-message: - prefix: "chore: " - - groups: - dependency-updates: - patterns: ["*"] - update-types: ["minor", "patch"] - - ignore: - - dependency-name: "@types/node" - update-types: ["version-update:semver-major"] - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index f0e7c30..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Upload Release Assets - -on: - release: - types: [created] # Trigger only after a Release is created - -jobs: - build-and-upload: - runs-on: ubuntu-latest - - # Must grant permission to allow the Action to modify the Release - permissions: - contents: write - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: pnpm - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 11 - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Build release archive - run: pnpm build:tar - - - name: Upload Release Asset - uses: softprops/action-gh-release@v2 - with: - files: dist.tar.gz - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}