bugfix #81
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: CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| CI: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create .env file | |
| run: | | |
| echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env | |
| echo "COOKIE_PREFIX=${{ vars.COOKIE_PREFIX }}" >> .env | |
| - name: Build and push Docker images | |
| run: | | |
| docker compose -f compose.prod.yml build | |
| docker compose -f compose.prod.yml push | |
| docker tag ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.REPOSITORY_NAME }}:latest ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.REPOSITORY_NAME }}:${{ github.sha }} | |
| docker push ${{ vars.DOCKERHUB_USERNAME }}/${{ vars.REPOSITORY_NAME }}:${{ github.sha }} | |
| CD: | |
| needs: CI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to VPS | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| script: | | |
| cd ./prikkert | |
| git pull | |
| docker compose -f compose.prod.yml pull | |
| docker compose -f compose.prod.yml up -d | |
| docker system prune -f |