-
Notifications
You must be signed in to change notification settings - Fork 398
88 lines (81 loc) · 3.14 KB
/
Copy pathdeploy.yml
File metadata and controls
88 lines (81 loc) · 3.14 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: Deploy static content
defaults:
run:
shell: bash
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: '2 0 * * *'
concurrency:
group: deploy-static-content
cancel-in-progress: true
env:
PYTHONUTF8: '1'
jobs:
run:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
cache-dependency-path: '.github/requirements.txt'
- name: Install Python dependencies
run: python -m pip install -r .github/requirements.txt
- name: Clone last deployed content
run: |
git clone --branch pages --depth 1 https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "${{ runner.temp }}/last_deploy"
- name: Cache Windhawk
id: cache-windhawk
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/windhawk
key: v1-${{ runner.os }}-1.7.3
- name: Extract Windhawk
if: steps.cache-windhawk.outputs.cache-hit != 'true'
run: |
installer_url="https://github.com/ramensoftware/windhawk/releases/download/v1.7.3/windhawk_setup.exe"
installer_path="${{ runner.temp }}/windhawk_setup.exe"
echo "Downloading $installer_url to $installer_path"
curl -L "$installer_url" -o "$installer_path"
extract_path="${{ runner.temp }}\windhawk"
echo "Extracting $installer_path to $extract_path"
MSYS_NO_PATHCONV=1 "$installer_path" /S /PORTABLE "/D=$extract_path"
- name: Install dependencies
run: npm install
- name: Prepare static content
run: npx tsx deploy.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WINDHAWK_MODS_LAST_DEPLOY_PATH: ${{ runner.temp }}\last_deploy
WINDHAWK_PATH: ${{ runner.temp }}\windhawk
- name: Archive mod images
run: |
# Copy last deployed images.
cp -R "${{ runner.temp }}/last_deploy/images" images
# Archive new images.
python scripts/archive_mod_images.py
- name: Deploy
run: |
src_dir=.
deploy_dir="${{ runner.temp }}/last_deploy"
deploy_branch=pages
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# echo Cloning the repository
# git clone --branch $deploy_branch --depth 1 --filter=blob:none --no-checkout https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "$deploy_dir"
echo Adding generated files to the repository
git --git-dir="$deploy_dir/.git" --work-tree="$src_dir" add -A
touch "$deploy_dir/.nojekyll"
git -C "$deploy_dir" add .nojekyll
echo Committing changes
git -C "$deploy_dir" diff-index --cached --quiet HEAD || git -C "$deploy_dir" commit -m "deploy: ${{ github.sha }}"
echo Pushing to GitHub
git -C "$deploy_dir" push origin $deploy_branch