pullpreview / action

A GitHub Action that starts preview deployments for your pull requests and branches. It can work with any application that has a valid Docker Compose file.
https://pullpreview.com
Other
161 stars 13 forks source link
action aws branch continuous-deployment continuous-integration deploy deployment docker docker-compose ephemeral-environments github-actions preview-environment pull-request staging

PullPreview

A GitHub Action that starts live environments for your pull requests and branches.

pullpreview Hacker News

Spin environments in one click

Once installed in your repository, this action is triggered any time a change is made to Pull Requests labelled with the pullpreview label, or one of the always-on branches.

When triggered, it will:

  1. Check out the repository code
  2. Provision a cheap AWS Lightsail instance, with docker and docker-compose set up
  3. Continuously deploy the specified pull requests and branches, using your docker-compose file(s)
  4. Report the preview instance URL in the GitHub UI

It is designed to be the no-nonsense, cheap, and secure alternative to services that require access to your code and force your app to fit within their specific deployment system and/or require a specific config file.

Useful for the entire team

Features

Preview environments that:

Installation & Usage

→ Please see the wiki for the full documentation.

Example

Workflow file with the master branch always on:

# .github/workflows/pullpreview.yml
name: PullPreview
on:
  # the schedule is optional, but helps to make sure no dangling resources are left when GitHub Action does not behave properly
  schedule:
    - cron: "30 2 * * *"
  push:
    branches:
      - main
  pull_request:
    types: [labeled, unlabeled, synchronize, closed, reopened]

jobs:
  deploy:
    if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.label.name == 'pullpreview' || contains(github.event.pull_request.labels.*.name, 'pullpreview')
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: pullpreview/action@v5
        with:
          # Those GitHub users will have SSH access to the servers
          admins: crohr,other-github-user
          # A preview environment will always exist for the main branch
          always_on: main
          # Use the cidrs option to restrict access to the live environments to specific IP ranges
          cidrs: "0.0.0.0/0"
          # PullPreview will use those 2 files when running docker-compose up
          compose_files: docker-compose.yml,docker-compose.pullpreview.yml
          # The preview URL will target this port
          default_port: 80
          # Use a 512MB RAM instance type instead of the default 2GB
          instance_type: nano
          # Ports to open on the server
          ports: 80,5432
        env:
          AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}"
          AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
          AWS_REGION: "us-east-1"

Is this free?

The code for this Action is completely open source, and licensed under the Prosperity Public License (see LICENSE).

If you are a non-profit individual, then it is free to run (in that case, please tell me so and/or pass the word around!).

In all other cases, you must buy a license. More details on pullpreview.com.

Thanks for reading until the end!