Skip to content

Commit 8feec06

Browse files
committed
update template workflows
1 parent 801d271 commit 8feec06

File tree

2 files changed

+20
-133
lines changed

2 files changed

+20
-133
lines changed

other-templates/github-workflows/deploy-reflex-site.template.yml

Lines changed: 16 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
# Deploys a reflex site
2-
name: Deploy Site
1+
name: Deploy Reflex Site
32

43
on:
54
push:
65
branches:
76
- main
8-
workflow_dispatch:
9-
inputs:
10-
branch:
11-
description: "Branch to deploy"
12-
required: true
13-
default: "main"
147

158
concurrency:
169
group: ${{ github.workflow }}-${{ github.ref }}
@@ -25,80 +18,21 @@ jobs:
2518
contents: read
2619

2720
steps:
28-
- name: Check variables set
29-
# Make it easier to see when environment setup is incorrect
30-
run: |
31-
if [ -z "${{ secrets.SSH_PRIVATE_KEY }}" ]; then
32-
echo "SSH_PRIVATE_KEY is not set"
33-
exit 1
34-
fi
35-
if [ -z "${{ vars.DROPLET_IP }}" ]; then
36-
echo "DROPLET_IP is not set"
37-
exit 1
38-
fi
39-
if [ -z "${{ vars.SITE_NAME }}" ]; then
40-
echo "SITE_NAME is not set"
41-
exit 1
42-
fi
43-
if [ -z "${{ vars.DOMAIN }}" ]; then
44-
echo "DOMAIN is not set"
45-
exit 1
46-
fi
47-
if [ -z "${{ secrets.RECAPTCHA_SITE_KEY }}" ]; then
48-
echo "RECAPTCHA_SITE_KEY is not set"
49-
exit 1
50-
fi
51-
if [ -z "${{ secrets.RECAPTCHA_SECRET_KEY }}" ]; then
52-
echo "RECAPTCHA_SECRET_KEY is not set"
53-
exit 1
54-
fi
55-
5621
- name: Checkout code
5722
uses: actions/checkout@v4
58-
with:
59-
ref: ${{ github.event.inputs.branch || github.ref }}
6023

61-
- name: Set up uv
62-
uses: astral-sh/setup-uv@v5
63-
with:
64-
version: "latest"
65-
# pyproject-file: "pyproject.toml"
66-
67-
- name: Create .env for frontend
24+
- name: Create .env
6825
run: |
69-
echo "DOMAIN=${{ vars.DOMAIN }}" >> .env
26+
echo "DOMAIN=${{ vars.DOMAIN }}" > .env
7027
echo "RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY }}" >> .env
7128
echo "RECAPTCHA_SECRET_KEY=${{ secrets.RECAPTCHA_SECRET_KEY }}" >> .env
7229
73-
- name: Build frontend
74-
run: |
75-
mkdir -p "tmp_frontend_zip"
76-
mkdir -p "site"
77-
uv run reflex export --frontend-only --zip-dest-dir "tmp_frontend_zip"
78-
unzip -q tmp_frontend_zip/frontend.zip -d site/
79-
rm -r "tmp_frontend_zip"
80-
81-
- name: Send frontend static files
82-
uses: appleboy/[email protected]
30+
- name: Deploy frontend
31+
uses: TimChild/webserver-template/actions/deploy-reflex-frontend@main
8332
with:
84-
host: ${{ vars.DROPLET_IP }}
85-
username: webadmin
86-
key: ${{ secrets.SSH_PRIVATE_KEY }}
87-
port: 22
88-
source: ./site/
89-
target: sites/${{ vars.SITE_NAME }}/static/
90-
strip_components: 2
91-
overwrite: true
92-
93-
- name: Update frontend files on server
94-
uses: appleboy/[email protected]
95-
with:
96-
host: ${{ vars.DROPLET_IP }}
97-
username: webadmin
98-
key: ${{ secrets.SSH_PRIVATE_KEY }}
99-
# Note: This script is present on the server from the webserver setup
100-
script: |
101-
./scripts/webserver-update-static-files.sh
33+
vps-ip: ${{ vars.VPS_IP }}
34+
site-name: ${{ vars.SITE_NAME }}
35+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
10236

10337
- name: Remove .env
10438
if: always()
@@ -110,76 +44,26 @@ jobs:
11044
name: production
11145
permissions:
11246
contents: read
113-
packages: write
11447

11548
steps:
11649
- name: Checkout code
11750
uses: actions/checkout@v4
118-
with:
119-
ref: ${{ github.event.inputs.branch || github.ref }}
120-
121-
- name: Set up Docker Buildx
122-
uses: docker/setup-buildx-action@v3
123-
124-
- name: Log in to GitHub Container Registry
125-
uses: docker/login-action@v3
126-
with:
127-
registry: ghcr.io
128-
username: ${{ github.actor }}
129-
password: ${{ secrets.GITHUB_TOKEN }}
130-
131-
- name: Set lower case owner name
132-
shell: bash
133-
run: |
134-
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
135-
env:
136-
OWNER: "${{ github.repository_owner }}"
137-
138-
- name: Build and push Docker image
139-
uses: docker/build-push-action@v5
140-
with:
141-
context: .
142-
file: backend.Dockerfile
143-
push: true
144-
tags: ghcr.io/${{ env.OWNER_LC }}/${{ vars.SITE_NAME }}-backend:latest
14551

14652
- name: Create .env for backend
14753
run: |
14854
echo "DOMAIN=${{ vars.DOMAIN }}" >> .env
14955
echo "RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY }}" >> .env
15056
echo "RECAPTCHA_SECRET_KEY=${{ secrets.RECAPTCHA_SECRET_KEY }}" >> .env
15157
152-
- name: Send .env file to server
153-
uses: appleboy/[email protected]
154-
with:
155-
host: ${{ vars.DROPLET_IP }}
156-
username: webadmin
157-
key: ${{ secrets.SSH_PRIVATE_KEY }}
158-
port: 22
159-
source: .env
160-
target: sites/${{ vars.SITE_NAME }}
161-
overwrite: true
162-
163-
- name: Set .env permissions
164-
uses: appleboy/[email protected]
165-
with:
166-
host: ${{ vars.DROPLET_IP }}
167-
username: webadmin
168-
key: ${{ secrets.SSH_PRIVATE_KEY }}
169-
script: |
170-
chmod 600 sites/${{ vars.SITE_NAME }}/.env
171-
172-
- name: Pull new backend image on server and restart updated container
173-
uses: appleboy/[email protected]
58+
- name: Deploy backend
59+
uses: TimChild/webserver-template/actions/deploy-reflex-backend@main
60+
permissions:
61+
packages: write
17462
with:
175-
host: ${{ vars.DROPLET_IP }}
176-
username: webadmin
177-
key: ${{ secrets.SSH_PRIVATE_KEY }}
178-
script: |
179-
# Log in to GitHub Container Registry
180-
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin && \
181-
docker pull ghcr.io/${{ env.OWNER_LC }}/${{ vars.SITE_NAME }}-backend:latest && \
182-
docker compose up -d
63+
vps-ip: ${{ vars.DROPLET_IP }}
64+
site-name: ${{ vars.SITE_NAME }}
65+
dotenv-path: .env
66+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
18367

18468
- name: Remove .env
18569
if: always()

other-templates/github-workflows/deploy-static-site.template.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Site
1+
name: Deploy Static Quarto Site
22

33
on:
44
push:
@@ -23,6 +23,9 @@ jobs:
2323
# NOTE: if the action fails to set up python or R environments correctly, you should be able to do that here before calling the action.
2424
# E.g., Make sure QUARTO_PYTHON points to a python with jupyter, pandas, plotly, etc. installed.
2525

26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
2629
- name: Deploy site via template action
2730
uses: TimChild/webserver-template/actions/deploy-quarto-static-site@main
2831
with:

0 commit comments

Comments
 (0)