name: "Deploy" on: push: branches: - "main" # This will make sure that only one deployment is running at a time concurrency: group: deployment cancel-in-progress: true env: WASP_VERSION: "0.16.0" # Put your server app name here SERVER_APP_NAME: "api" # After you know the server URL, put the URL here SERVER_APP_URL: "https://api.xx.com" # Put your client app name here CLIENT_APP_NAME: "client name" DOCKER_REGISTRY: "ghcr.io" DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }} # This secret is provided by GitHub by default and is used to authenticate with the Container registry DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} jobs: build-and-push-images: permissions: contents: read packages: write runs-on: ubuntu-latest # REMOVE this whole block if your app is not in the `app` folder defaults: run: working-directory: ./ steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set short SHA id: vars run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV - name: Log in to the Container registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ env.DOCKER_REGISTRY_USERNAME }} password: ${{ env.DOCKER_REGISTRY_PASSWORD }} - name: (server) Extract metadata for Docker id: meta-server uses: docker/metadata-action@v5 with: images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_USERNAME }}/${{ env.SERVER_APP_NAME }} - name: (client) Extract metadata for Docker id: meta-client uses: docker/metadata-action@v5 with: images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_USERNAME }}/${{ env.CLIENT_APP_NAME }} - name: Install Wasp shell: bash run: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v ${{ env.WASP_VERSION }} - name: Build Wasp app shell: bash run: wasp build - name: (client) Build shell: bash run: | cd ./.wasp/build/web-app REACT_APP_API_URL=${{ env.SERVER_APP_URL }} npm run build - name: (client) Prepare the Dockerfile shell: bash run: | cd ./.wasp/build/web-app echo "FROM pierrezemb/gostatic" > Dockerfile echo "CMD [\"-fallback\", \"index.html\", \"-enable-logging\"]" >> Dockerfile echo "COPY ./build /srv/http" >> Dockerfile - name: (server) Build and push Docker image uses: docker/build-push-action@v6 with: # REMOVE the `app` bit from the path if your app is not in the `app` folder context: ./.wasp/build # REMOVE the `app` bit from the path if your app is not in the `app` folder file: ./.wasp/build/Dockerfile push: true tags: ${{ steps.meta-server.outputs.tags }} labels: ${{ steps.meta-server.outputs.labels }} - name: (client) Build and push Docker image uses: docker/build-push-action@v6 with: # REMOVE the `app` bit from the path if your app is not in the `app` folde context: ./.wasp/build/web-app # REMOVE the `app` bit from the path if your app is not in the `app` folder file: ./.wasp/build/web-app/Dockerfile push: true tags: ${{ steps.meta-client.outputs.tags }} labels: ${{ steps.meta-client.outputs.labels }} - name: (server) Deploy to Caprover uses: caprover/deploy-from-github@v1.1.2 with: server: ${{ secrets.CAPROVER_SERVER }} app: ${{ env.SERVER_APP_NAME }} token: ${{ secrets.SERVER_APP_TOKEN }} image: ${{ steps.meta-server.outputs.tags }} - name: (client) Deploy to Caprover uses: caprover/deploy-from-github@v1.1.2 with: server: ${{ secrets.CAPROVER_SERVER }} app: ${{ env.CLIENT_APP_NAME }} token: ${{ secrets.CLIENT_APP_TOKEN }} image: ${{ steps.meta-client.outputs.tags }}