diff --git a/README.md b/README.md index 3087ea3..1569690 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,48 @@ # deploy-action 🚀 -Github Action to deploy with Wasp to Fly.io +Github Action to deploy Wasp apps to Fly.io or Railway. -## How to setup Deploy on Push +Read more on each platform in our [docs](https://wasp.sh/docs/deployment/deployment-methods/wasp-deploy/overview). -### Launch your app locally once ⚠️ +## Action Inputs -- You should first launch your app locally with `wasp deploy fly launch `. -- After your app is launched, make sure to commit the `fly-server.toml` and `fly-client.toml` files. +### General -### Action Inputs +- `platform` (required): 'fly' or 'railway' +- `node-version` (optional): Node.js version to use, defaults to '22' +- `server-url` (optional): If you have configured a custom domain for your server, provide its URL here. If this is not defined, Wasp will default to using the deployment URL provided by the platform. +- `wasp-version` (optional): Specific Wasp version to use, defaults to latest -#### Get your API token from Fly.io +### Fly.io Specific -- Login with Fly.io and go here: https://fly.io/user/personal_access_tokens -- Click `Create token` and copy that value. -- Add your Fly.io token as a repository secret e.g. calling it `FLY_TOKEN` +- `fly-token` (required for Fly): Fly.io API token - Read more about how to do it: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository +### Railway Specific -#### Setting a Custom Server URL +- `railway-token` (required for Railway): Railway API token +- `project-name` (required for Railway): Project name, max 25 characters -If you have configured a custom domain for your server, you can specify it as a repository secret named `SERVER_URL`. If this is not defined, Wasp will default to using the `-server.fly.dev` address. +## Github Action Secrets For detailed instructions on setting up repository secrets, visit: [GitHub Docs: Creating Encrypted Secrets for a Repository](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository). -#### Setting a Wasp Version +## Deploying to Fly.io -You can specify the version of Wasp to use for deployment by setting the `wasp-version` input. If this is not defined, Wasp will default to using the latest version. +- Prerequisites: Run `wasp deploy fly launch ` locally first +- Commit the generated `fly-server.toml` and `fly-client.toml` files to repository +- Add Github secrets: + - [Get Fly.io API token](https://fly.io/user/personal_access_tokens) and add it as repository secret called `FLY_TOKEN` -### Add the Action to your repo - -Create a file called `deploy.yml` in `.github/workflows` folder in your repo with this content: +### Example ```yml -name: Deploy to Fly +name: Deploy to Fly.io on: push: branches: - "main" + jobs: deploy: name: Deploy with Wasp @@ -47,12 +50,41 @@ jobs: steps: - uses: wasp-lang/deploy-action@main with: - # Required: Fly.io API token + platform: fly fly-token: ${{ secrets.FLY_TOKEN }} - # Optional: Override the default Fly server URL with a custom domain - server-url: ${{ secrets.SERVER_URL }} - # Optional: Set the Wasp version to use, defaults to latest - wasp-version: "0.16.0" + node-version: "22" # Optional, defaults to 22 + server-url: ${{ secrets.SERVER_URL }} # Optional + wasp-version: "0.18.0" # Optional ``` -Notice that we are using the `secrets.FLY_TOKEN` so Wasp knows how to deploy. +## Deploying to Railway + +### Requirements + +- Prerequisites: Run `wasp deploy railway launch ` locally first +- Add Github secrets: + - Get a Railway **project token** and add it as repository secret called `RAILWAY_TOKEN` + +### Example + +```yml +name: Deploy to Railway + +on: + push: + branches: + - "main" + +jobs: + deploy: + name: Deploy with Wasp + runs-on: ubuntu-latest + steps: + - uses: wasp-lang/deploy-action@main + with: + platform: railway + railway-token: ${{ secrets.RAILWAY_TOKEN }} + project-name: my-app # Required, max 25 characters + server-url: ${{ secrets.SERVER_URL }} # Optional + wasp-version: "0.18.0" # Optional +``` diff --git a/action.yml b/action.yml index b6510ca..a4c0d39 100644 --- a/action.yml +++ b/action.yml @@ -1,19 +1,38 @@ name: "Wasp Deploy" -description: "Deploy with Wasp to Fly.io" +description: "Deploy with Wasp to Fly.io or Railway" inputs: - fly-token: - description: "Fly.io API token" + platform: + description: "Deployment platform: 'fly' or 'railway'" required: true + fly-token: + description: "Fly.io API token (required when platform is 'fly')" + required: false + railway-token: + description: "Railway API token (required when platform is 'railway')" + required: false + project-name: + description: "Project/app name (required for Railway, max 25 characters)" + required: false server-url: - description: "Server URL for the React app" + description: "Server URL used by the React app" required: false wasp-version: description: "Version of Wasp to use for deployment" required: false + node-version: + description: "Node.js version to use" + required: false + default: "22" runs: using: "composite" steps: - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + - name: Install Wasp shell: bash run: | @@ -24,14 +43,33 @@ runs: curl -sSL https://get.wasp.sh/installer.sh | sh -s -- $VERSION_PARAM - name: Install Flyctl + if: ${{ inputs.platform == 'fly' }} uses: superfly/flyctl-actions/setup-flyctl@master - - name: Deploy + + - name: Install Railway CLI + if: ${{ inputs.platform == 'railway' }} + shell: bash + run: | + npm install -g @railway/cli + railway --version + + - name: Set custom server URL if provided + shell: bash run: | if [ -n "${{ inputs.server-url }}" ]; then - REACT_APP_API_URL=${{ inputs.server-url }} wasp deploy fly deploy - else - wasp deploy fly deploy + echo "REACT_APP_API_URL=${{ inputs.server-url }}" >> $GITHUB_ENV fi + + - name: Deploy to Fly.io + if: ${{ inputs.platform == 'fly' }} shell: bash + run: wasp deploy fly deploy env: FLY_API_TOKEN: ${{ inputs.fly-token }} + + - name: Deploy to Railway + if: ${{ inputs.platform == 'railway' }} + shell: bash + run: wasp deploy railway deploy "${{ inputs.project-name }}" + env: + RAILWAY_API_TOKEN: ${{ inputs.railway-token }}