Merge pull request #127 from Lycoon/dev #39
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 & Deploy Staging | |
| on: | |
| push: | |
| branches: [staging] | |
| jobs: | |
| build_and_push: | |
| runs-on: ubuntu-latest | |
| env: | |
| IMAGE_NAME: ghcr.io/lycoon/scriptio-app | |
| steps: | |
| - name: Checkout the repo | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set environment variables | |
| run: | | |
| echo "APP_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
| echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Staging | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:staging | |
| ${{ env.IMAGE_NAME }}:staging-${{ env.APP_VERSION }} | |
| build-args: | | |
| NEXT_PUBLIC_API_URL=https://staging.scriptio.app | |
| NEXT_PUBLIC_COMMIT_SHA=${{ env.COMMIT_SHA }} | |
| NEXT_PUBLIC_APP_VERSION=${{ env.APP_VERSION }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build_and_push | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| - name: Copy docker-compose to VPS | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_SECRET }} | |
| port: ${{ secrets.SSH_PORT }} | |
| source: docker-compose.yml | |
| target: ${{ secrets.APP_PATH }} | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_SECRET }} | |
| port: ${{ secrets.SSH_PORT }} | |
| script: | | |
| set -e | |
| docker image prune -af | |
| cd ${{ secrets.APP_PATH }} | |
| docker compose pull app-staging | |
| docker compose --env-file .env.staging --profile staging up -d --force-recreate |