Repository navigation
Merge pull request #1 from Aparencia/dev #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Website | |
| on: | |
| push: | |
| branches: [main] | |
| paths: ['website/**'] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| cache-dependency-path: website/package-lock.json | |
| - name: Install dependencies and build | |
| run: | | |
| cd website | |
| npm ci | |
| npm run build | |
| - name: Ensure target directory exists | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: mkdir -p /opt/Entropydecrease/website | |
| - name: Upload static files to server | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| source: website/out/* | |
| target: /opt/Entropydecrease/website | |
| strip_components: 2 | |
| rm: true | |
| - name: Restart Nginx and verify deployment | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| # scp 的 rm:true 会重建挂载目录导致 bind mount 失效,必须重启容器 | |
| docker restart entropy-decrease-nginx | |
| sleep 5 | |
| curl -sf https://entropydecrease.com/ | grep -q "熵减" || exit 1 | |
| - name: Notify IndexNow | |
| run: | | |
| curl -sf -X POST "https://api.indexnow.org/indexnow" \ | |
| -H "Content-Type: application/json; charset=utf-8" \ | |
| -d '{ | |
| "host": "entropydecrease.com", | |
| "key": "2483a0d298b94b62a30be65fce88940e", | |
| "keyLocation": "https://entropydecrease.com/2483a0d298b94b62a30be65fce88940e.txt", | |
| "urlList": [ | |
| "https://entropydecrease.com/", | |
| "https://entropydecrease.com/download", | |
| "https://entropydecrease.com/story", | |
| "https://entropydecrease.com/support" | |
| ] | |
| }' || echo "IndexNow notify failed (non-blocking)" |