-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (61 loc) · 2.27 KB
/
build-deploy.yml
File metadata and controls
73 lines (61 loc) · 2.27 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
name: Build and Remote Deploy
on:
push:
branches:
- main
- 'v*'
env:
CURRENT_MAJOR_VERSION: "4.0"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: "latest"
- name: Set up Python
run: uv python install v3
- name: Configure Git and Fetch Deploy Branch
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git fetch origin deploy:deploy
- name: Build and Alias
run: |
BRANCH_NAME=${{ github.ref_name }}
# Install everything from pyproject.toml including mike
uv sync
if [ "$BRANCH_NAME" == "main" ]; then
echo "Deploying MAIN as Version ${{ env.CURRENT_MAJOR_VERSION }} (Latest)"
uv run mike deploy --deploy-prefix package -b deploy ${{ env.CURRENT_MAJOR_VERSION }} latest --update-aliases --push
uv run mike set-default latest --push --deploy-prefix package -b deploy
else
# Extracts version from branch name (e.g., v3.0 -> 3.0)
VERSION=$(echo $BRANCH_NAME | sed 's/^v//')
echo "Deploying LEGACY Version: $VERSION"
uv run mike deploy --deploy-prefix package -b deploy $VERSION --push
fi
- name: Switch Workspace to HTML Branch
run: git checkout deploy
- name: Deploy Entire Collection to Server
uses: Burnett01/rsync-deployments@v8
with:
switches: -avzr --delete
path: ./package/
remote_path: ${{ secrets.SERVER_PATH }}
remote_host: ${{ secrets.SERVER_HOST }}
remote_user: ${{ secrets.SERVER_USER }}
remote_key: ${{ secrets.SERVER_SSH_KEY }}
- name: Invalidate Cloudflare Cache
if: success()
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE_ID }}/purge_cache" \
-H "Authorization: Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'