Deploying a Vapor App with GitHub Actions

Published Jul 3, 20232 min read

This guide serves as a quick reminder on deploying a Vapor application using GitHub Actions. It is not a fully detailed tutorial, but rather a brief rundown of the steps involved.

Step 1: Create a deploy.yml file

To start with, we need to create a directory for our workflow files (if it doesn't already exist), and then create a new workflow file, deploy.yml.

Open your terminal and navigate to your project's directory. Run the following commands:

mkdir -p .github/workflows  # creates the workflows directory
touch .github/workflows/deploy.yml  # creates the deploy.yml file

Step 2: Configure GitHub Actions

Next, we will configure our deploy.yml file. This file defines our GitHub Actions workflow. Below is an example of what this configuration might look like:

name: Deploy

        branches: [main]

        runs-on: ubuntu-latest
            - name: Checkout code
              uses: actions/checkout@v2
            - name: Setup PHP
              uses: shivammathur/setup-php@v2
                  php-version: 8.2
                  tools: composer:v2
                  coverage: none
            - name: Install Composer dependencies
              run: composer install --prefer-dist --no-interaction --no-dev
            - name: Require Vapor CLI
              run: composer global require laravel/vapor-cli
            - name: Deploy Environment
              run: vapor deploy production --without-waiting
                  VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}

This workflow is configured to run every time there's a push to the main branch.

Step 3: Create an API token

To allow GitHub Actions to interact with Vapor, we need an API token. Visit and create a new API token.

Step 4: Add the API token to GitHub Secrets

After creating the API token, go to your GitHub repository, navigate to Settings -> Secrets, and click on New repository secret. Name the secret VAPOR_API_TOKEN and paste the value of the API token you created.

With that, your Vapor application is ready to be automatically deployed via GitHub Actions on every push to the main branch.