Skip to content

Instantly share code, notes, and snippets.

@crohr
Last active January 25, 2024 08:57
Show Gist options
  • Save crohr/bbd4ef4f19a4322f075d58131dce7891 to your computer and use it in GitHub Desktop.
Save crohr/bbd4ef4f19a4322f075d58131dce7891 to your computer and use it in GitHub Desktop.
Example PullPreview workflow
# .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 * * *"
# optional, only use if you want to have an always-on branch
push:
branches:
- main
pull_request:
types: [labeled, unlabeled, synchronize, closed, reopened]
# make sure only one workflow runs at the same time
concurrency: ${{ github.ref }}
jobs:
deploy:
permissions:
contents: read # to fetch code (actions/checkout)
deployments: write # to delete deployments
pull-requests: write # to remove labels
statuses: write # to create commit status
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@v2
- uses: pullpreview/action@v5
with:
# Those GitHub users will have SSH access to the servers
admins: your-github-username,other-github-username
# Optional: a preview environment will always exist for the main branch
always_on: main
# Optional: use the cidrs option to restrict access to the live environments to specific IP ranges
cidrs: "0.0.0.0/0"
# Optional: specify the compose files to use
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment