Merge pull request #35 from Team-Gamism/release/1.3.0 #24
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 pushandpull-server | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
| - name: Build Docker image | |
| run: | | |
| docker build \ | |
| -t seanyee1227/pushandpull-server:latest \ | |
| -f PushAndPull/deploy/prod.dockerfile \ | |
| PushAndPull | |
| - name: Push Docker image | |
| run: docker push seanyee1227/pushandpull-server:latest | |
| - name: Copy compose file to server | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| port: ${{ secrets.SSH_PORT }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| source: "PushAndPull/deploy/compose.prod.yaml" | |
| target: "~/deploy/" | |
| strip_components: 2 | |
| - name: Deploy via Docker Compose | |
| uses: appleboy/ssh-action@v0.1.10 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| port: ${{ secrets.SSH_PORT }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| mkdir -p ~/deploy | |
| printf 'DB_CONNECTION_STRING=%s\nREDIS_CONNECTION_STRING=%s\nSTEAM_WEB_API_KEY=%s\nSTEAM_APP_ID=%s\n' \ | |
| "${{ secrets.DB_CONNECTION_STRING }}" \ | |
| "${{ secrets.REDIS_CONNECTION_STRING }}" \ | |
| "${{ secrets.STEAM_WEB_API_KEY }}" \ | |
| "${{ secrets.STEAM_APP_ID }}" \ | |
| > ~/deploy/.env | |
| docker compose -f ~/deploy/compose.prod.yaml --env-file ~/deploy/.env pull | |
| docker compose -f ~/deploy/compose.prod.yaml --env-file ~/deploy/.env up -d | |
| sleep 5 | |
| docker ps | grep pushandpull-server | |
| docker logs pushandpull-server --tail 20 |