Fix GHCR repository names #9
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: Build and Deploy | |
| on: | |
| push: | |
| branches: ["main"] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GHCR | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Build and Push Image | |
| run: | | |
| IMAGE=ghcr.io/${{ github.repository_owner }}/stmorg:latest | |
| docker build -t $IMAGE . | |
| docker push $IMAGE | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to VPS | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.VPS_HOST }} | |
| username: ${{ secrets.VPS_USER }} | |
| key: ${{ secrets.VPS_SSH_KEY }} | |
| script: | | |
| cd /home/weberqbot/apps/stmorg | |
| echo "🔐 Login to GHCR..." | |
| echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin | |
| echo "📂 Pull latest repo..." | |
| git pull origin main | |
| echo "📥 Pull latest image..." | |
| docker compose pull | |
| echo "🔄 Restart containers..." | |
| docker compose up -d --force-recreate --remove-orphans | |
| echo "🧹 Cleanup old images..." | |
| docker image prune -f | |
| echo "✅ Deployment Complete!" | |