Switch preview from static build to DSPublisher dev server #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Preview Deploy | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, closed] | |
| branches: [main] | |
| concurrency: | |
| group: preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| env: | |
| FLY_APP: docs-preview-pr-${{ github.event.pull_request.number }} | |
| FLY_ORG: ${{ vars.FLY_ORG || 'personal' }} | |
| jobs: | |
| build-and-deploy: | |
| if: github.event.action != 'closed' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up Fly CLI | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Create Fly app (if not exists) | |
| run: | | |
| flyctl apps create "${{ env.FLY_APP }}" --org "${{ env.FLY_ORG }}" 2>/dev/null || true | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Set Fly secrets | |
| run: | | |
| echo "${{ secrets.VAADIN_PRO_KEY }}" | flyctl secrets set VAADIN_PRO_KEY=- --app "${{ env.FLY_APP }}" --stage | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Generate fly.toml | |
| run: | | |
| cat > fly.toml <<EOF | |
| app = "${{ env.FLY_APP }}" | |
| primary_region = "ams" | |
| [build] | |
| dockerfile = "Dockerfile.preview" | |
| [http_service] | |
| internal_port = 8210 | |
| force_https = true | |
| [[vm]] | |
| size = "shared-cpu-1x" | |
| memory = "1024mb" | |
| EOF | |
| - name: Deploy to Fly.io | |
| run: | | |
| flyctl deploy \ | |
| --ha=false \ | |
| --remote-only \ | |
| --build-secret VAADIN_PRO_KEY="${{ secrets.VAADIN_PRO_KEY }}" | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| - name: Comment preview URL on PR | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: preview-deploy | |
| message: | | |
| ### Preview Deployment | |
| This PR has been deployed for preview. | |
| **URL:** https://${{ env.FLY_APP }}.fly.dev | |
| _Built from ${{ github.sha }}_ | |
| cleanup: | |
| if: github.event.action == 'closed' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Fly CLI | |
| uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Destroy Fly app | |
| run: | | |
| flyctl apps destroy "${{ env.FLY_APP }}" --yes 2>/dev/null || true | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |