Skip to content

Instantly share code, notes, and snippets.

@crohr
Last active January 25, 2024 08:57
Show Gist options
  • Select an option

  • Save crohr/bbd4ef4f19a4322f075d58131dce7891 to your computer and use it in GitHub Desktop.

Select an option

Save crohr/bbd4ef4f19a4322f075d58131dce7891 to your computer and use it in GitHub Desktop.

Revisions

  1. crohr revised this gist Jul 7, 2023. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion pullpreview.yml
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,9 @@ on:
    pull_request:
    types: [labeled, unlabeled, synchronize, closed, reopened]

    # make sure only one workflow runs at the same time
    concurrency: ${{ github.ref }}

    jobs:
    deploy:
    permissions:
    @@ -36,7 +39,7 @@ jobs:
    # The preview URL will target this port
    default_port: 80
    # Use a 512MB RAM instance type instead of the default 2GB
    instance_type: nano_2_0
    instance_type: nano
    # Ports to open on the server
    ports: 80,5432
    env:
  2. crohr revised this gist Jun 1, 2023. No changes.
  3. crohr revised this gist Jun 1, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions pullpreview.yml
    Original file line number Diff line number Diff line change
    @@ -14,10 +14,10 @@ on:
    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
    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
  4. crohr revised this gist May 31, 2023. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions pullpreview.yml
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ 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
    @@ -12,6 +13,11 @@ on:

    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
    @@ -20,12 +26,12 @@ jobs:
    - uses: pullpreview/action@v5
    with:
    # Those GitHub users will have SSH access to the servers
    admins: crohr,other-github-user
    # A staging environment will always exist for the master branch
    admins: your-github-username,other-github-username
    # Optional: 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
    # Optional: 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
    # 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
  5. crohr created this gist Mar 10, 2023.
    39 changes: 39 additions & 0 deletions pullpreview.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    # .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@v2
    - uses: pullpreview/action@v5
    with:
    # Those GitHub users will have SSH access to the servers
    admins: crohr,other-github-user
    # A staging environment will always exist for the master 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_2_0
    # 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"