This repository was archived by the owner on Nov 29, 2025. It is now read-only.
Merge pull request #48 from MicroPyramid/dev #21
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 (Docker) | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| tags: ghcr.io/${{ github.repository }}:latest | ||
| - name: Setup SSH | ||
| uses: webfactory/ssh-agent@v0.8.0 | ||
| with: | ||
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
| - name: Add host key to known_hosts | ||
| run: | | ||
| mkdir -p ~/.ssh | ||
| ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | ||
| - name: Deploy on server (pull and restart container) | ||
| run: | | ||
|
Check failure on line 48 in .github/workflows/build-deploy.yml
|
||
| ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} && \ | ||
| docker pull ghcr.io/${{ github.repository }}:latest && \ | ||
| docker stop svelte-crm || true && docker rm svelte-crm || true && \ | ||
| docker run -d --name svelte-crm --restart always -p 3000:3000 \ | ||
| -e NODE_ENV=production \ | ||
| -e DATABASE_URL=\"${{ secrets.DATABASE_URL }}\" \ | ||
| --env-file ${{ secrets.ENV_FILE_PATH:-/home/${{ secrets.SERVER_USER }}/.env }} \ | ||
| ghcr.io/${{ github.repository }}:latest" | ||