-
Notifications
You must be signed in to change notification settings - Fork 216
88 lines (70 loc) · 2.2 KB
/
preview-deploy.yml
File metadata and controls
88 lines (70 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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: 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 = "256mb"
EOF
- name: Deploy to Fly.io
run: |
flyctl deploy \
--ha=false \
--remote-only \
--build-arg 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 }}