3535 commit : " chore: release versions"
3636 title : " chore: release versions"
3737 env :
38- GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
39- deploy :
40- name : Deploy to VPS
41- runs-on : ubuntu-latest
42- needs : [release]
43- if : needs.release.outputs.published == 'true'
44- steps :
45- - name : Check if khaxyrewrite was published
46- id : check
47- run : |
48- PACKAGES='${{ needs.release.outputs.publishedPackages }}'
49- echo "Published packages: $PACKAGES"
50-
51- if [ -z "$PACKAGES" ] || [ "$PACKAGES" = "false" ]; then
52- echo "should_deploy=false" >> $GITHUB_OUTPUT
53- echo "No packages were published"
54- elif echo "$PACKAGES" | jq -e '.[] | select(.name == "khaxyrewrite")' > /dev/null 2>&1; then
55- echo "should_deploy=true" >> $GITHUB_OUTPUT
56- echo "khaxyrewrite was published, will deploy"
57- else
58- echo "should_deploy=false" >> $GITHUB_OUTPUT
59- echo "khaxyrewrite was not in the published packages"
60- fi
61- - name : SSH and Deploy
62- if : steps.check.outputs.should_deploy == 'true'
63- uses : appleboy/ssh-action@v1.0.3
64- with :
65- host : ${{ secrets.VPS_IP }}
66- username : ${{ secrets.VPS_USER }}
67- key : ${{ secrets.VPS_SSH_KEY }}
68- script : |
69- set -e
70- cd ~/Khaxy
71-
72- # 1. Update local tags from GitHub
73- git fetch --all --tags
74-
75- # 2. Get the most recent tag created by Changesets
76- LATEST_TAG=$(git tag -l "khaxyrewrite@*" --sort=-v:refname | head -n1)
77-
78- if [ -z "$LATEST_TAG" ]; then
79- echo "❌ No khaxyrewrite tag found!"
80- exit 1
81- fi
82-
83- echo "🚀 Deploying release: $LATEST_TAG"
84- git checkout --force $LATEST_TAG
85-
86- # 3. Docker Zero-Downtime Update
87- echo "🏗️ Building and deploying with Docker..."
88- docker-compose build
89- docker-compose up -d
90-
91- # 4. Cleanup
92- echo "🧹 Cleaning up old images..."
93- docker image prune -f
94-
95- echo "✅ Deployment Complete!"
38+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments