Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing deploying to Cloudflare Pages #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 18 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ name: "Deploy"
on:
push:
branches:
- "main"
- cloudflare-client

# This will make sure that only one deployment is running at a time
concurrency:
group: deployment
cancel-in-progress: true
group: deployment
cancel-in-progress: true

env:
WASP_VERSION: "0.14.0"
# Put your server app name here
SERVER_APP_NAME: "render-ghcr-server"
# After you know the server URL, put the URL here
SERVER_APP_URL: "https://render-ghcr-server-main.onrender.com"
# Put your client app name here
CLIENT_APP_NAME: "render-ghcr-client"
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 }}
# Put your client Cloudflare app name here - make sure to create the app in Cloudflare Pages
# npx wrangler pages project create render-ghcr-client
CLIENT_CLOUDFLARE_APP_NAME: "render-ghcr-client"
WASP_TELEMETRY_DISABLED: 1

jobs:
Expand Down Expand Up @@ -49,12 +50,6 @@ jobs:
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 }}
Expand All @@ -69,14 +64,6 @@ jobs:
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:
Expand All @@ -86,21 +73,19 @@ jobs:
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:
context: ./.wasp/build/web-app
file: ./.wasp/build/web-app/Dockerfile
push: true
tags: ${{ steps.meta-client.outputs.tags }}
labels: ${{ steps.meta-client.outputs.labels }}

# You can get the webhook URL from the Render dashboard
# Put them in the repository secrets under RENDER_CLIENT_WEBHOOK_URL and RENDER_SERVER_WEBHOOK_URL
- name: Trigger Deploy Webhooks
# Put them in the repository secrets under RENDER_SERVER_WEBHOOK_URL
- name: (server) Trigger Deploy Webhooks
env:
CLIENT_URL: ${{ secrets.RENDER_CLIENT_WEBHOOK_URL }}
SERVER_URL: ${{ secrets.RENDER_SERVER_WEBHOOK_URL }}
run: |
curl "${{ env.CLIENT_URL }}"
curl "${{ env.SERVER_URL }}"
curl "${{ env.SERVER_URL }}"

- name: (client) Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
# Make sure to add CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets
# You can get the API token from the Cloudflare dashboard
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./.wasp/build/web-app/build --project-name=${{ env.CLIENT_CLOUDFLARE_APP_NAME }} --commit-dirty=true --branch=main