Skip to content

ci: add preview via fly #13

ci: add preview via fly

ci: add preview via fly #13

Workflow file for this run

name: Preview
on:
pull_request:
types: [opened, reopened, synchronize, closed]
concurrency:
group: pr-${{ github.event.number }}
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.changes.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Detect changes in migrations
id: changes
uses: tj-actions/changed-files@v37
with:
json: "true"
escape_json: "false"
dir_names: "true"
dir_names_exclude_current_dir: "true"
dir_names_max_depth: 1
files: |
tasks/**
- name: Summarize changes
run: |
echo "projects: $projects" >> $GITHUB_STEP_SUMMARY
env:
projects: ${{ steps.changes.outputs.all_changed_files }}
preview:
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.projects != '[]'
strategy:
matrix:
project: ${{ fromJson(needs.detect-changes.outputs.projects) }}
environment:
name: pr-${{ github.event.number }}-${{ matrix.project }}
url: ${{ steps.deploy.outputs.url }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_REGION: ams
FLY_ORG: helpwave-staging
steps:
- uses: actions/checkout@v3
# --copy-config uses a fly.toml from the current working directory
# as a base configuration for the new app
- name: Prepare fly.toml for `fly launch --copy-config`
run: |
cp ${{ matrix.project }}/fly.toml .
sed -i "s/\.\.\/Dockerfile/Dockerfile/g" fly.toml
- name: Deploy preview to Fly
id: deploy
uses: superfly/[email protected]
with:
name: pr-${{ github.event.number }}-${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ matrix.project }}
config: ${{ matrix.project }}/fly.toml
# - name: Clean up GitHub environment
# uses: strumwolf/delete-deployment-environment@v2
# # if: ${{ github.event.action == 'closed' }}
# with:
# token: ${{ secrets.HW_GITHUB_TOKEN_PREVIEW_ACTION }}
# environment: pr-${{ github.event.number }}-${{ matrix.project }}