diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml new file mode 100644 index 0000000..7f78b24 --- /dev/null +++ b/.github/workflows/dev.yaml @@ -0,0 +1,118 @@ +name: "Dev" + +on: + push: + paths: + - ".github/workflows/dev.yaml" + - ".vitepress/**" + - "docs/**" + - "package*.json" + workflow_dispatch: + +env: + SSH_HOST: ${{ secrets.DEV_DEPLOY_HOST }} + SSH_PORT: ${{ secrets.DEV_DEPLOY_PORT }} + SSH_USER: ${{ secrets.DEV_DEPLOY_USER }} + SSH_PASS: ${{ secrets.DEV_DEPLOY_PASS }} + SSH_DEST: /static + +concurrency: + group: dev + cancel-in-progress: true + +jobs: + build: + name: "Build" + runs-on: ubuntu-latest + timeout-minutes: 10 + + if: ${{ !contains(github.event.head_commit.message, '#nodev') }} + + permissions: + contents: read + + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: "Setup Node 24" + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: "Install Dependencies" + run: | + npm ci + + - name: "Run Build" + run: | + npm run build + + - name: "Upload Artifact" + uses: actions/upload-artifact@v4 + with: + name: "artifact" + path: .vitepress/dist + + deploy: + name: "Deploy" + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: build + + permissions: + pages: write + id-token: write + + environment: + name: dev + url: https://dev-static.cssnr.com/ + + steps: + - name: "Debug Variables" + continue-on-error: true + run: | + echo "env.SSH_HOST: ${{ env.SSH_HOST }}" + echo "env.SSH_PORT: ${{ env.SSH_PORT }}" + echo "env.SSH_USER: ${{ env.SSH_USER }}" + echo "env.SSH_PASS: ${{ env.SSH_PASS }}" + echo "env.SSH_DEST: ${{ env.SSH_DEST }}" + + - name: "Download Artifact" + uses: actions/download-artifact@v5 + with: + name: "artifact" + + - name: "Debug Artifact" + continue-on-error: true + run: | + tree . + + - name: "Setup SSH" + run: | + mkdir -p "${HOME}/.ssh" + chmod 0700 "${HOME}/.ssh" + ssh-keyscan -p "${{ env.SSH_PORT }}" -H "${{ env.SSH_HOST }}" \ + | tee -a "${HOME}/.ssh/known_hosts" + + - name: "No Robots" + run: | + cat < robots.txt + User-agent: * + Disallow: / + EOF + + - name: "Deploy Artifact" + env: + SSHPASS: ${{ env.SSH_PASS }} + run: | + sshpass -e rsync -aPvh --delete -e 'ssh -p ${{ env.SSH_PORT }}' \ + ./ "${{ env.SSH_USER }}"@"${{ env.SSH_HOST }}":"${{ env.SSH_DEST }}" + + - name: "Send Discord Notification" + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "https://dev-static.cssnr.com/" diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index a0a2ec3..9c1f374 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -1,15 +1,15 @@ name: "Pages" on: - push: - branches: - - "master" - paths: - - "docs/**" - - ".vitepress/**" - - "package.json" - - ".github/workflows/pages.yaml" workflow_dispatch: + #push: + # branches: + # - "master" + # paths: + # - "docs/**" + # - ".vitepress/**" + # - "package.json" + # - ".github/workflows/pages.yaml" env: CRAWLER_ID: "7a46f2b7-7169-4936-986d-21391c3134d4"