Skip to content

Commit 0669c00

Browse files
committed
add ci
1 parent 0515745 commit 0669c00

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

.github/workflows/build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build
2+
on:
3+
push:
4+
paths-ignore:
5+
- '.github/workflows/tag.yml'
6+
workflow_dispatch:
7+
inputs:
8+
repo:
9+
description: 'repo name'
10+
required: false
11+
schedule:
12+
- cron: "0 0 * * *"
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
run-name: Build ${{ github.event.inputs.repo }}
21+
22+
jobs:
23+
deploy:
24+
concurrency:
25+
group: ${{ github.sha }}
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
name: Build Website
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Setup Bun
38+
uses: oven-sh/setup-bun@v2
39+
with:
40+
bun-version: latest
41+
42+
- name: Clean cache (full rebuild)
43+
if: ${{ !github.event.inputs.repo }}
44+
run: |
45+
rm -rf .cache
46+
rm -rf dist
47+
echo "Cleaned cache for full rebuild"
48+
49+
- name: Restore .cache directory (incremental)
50+
if: ${{ github.event.inputs.repo }}
51+
uses: actions/cache/restore@v4
52+
with:
53+
path: .cache
54+
key: ${{ runner.os }}-astro-cache-${{ github.run_id }}
55+
restore-keys: ${{ runner.os }}-astro-cache-
56+
57+
- name: Restore dist directory (incremental)
58+
if: ${{ github.event.inputs.repo }}
59+
uses: actions/cache/restore@v4
60+
with:
61+
path: dist
62+
key: ${{ runner.os }}-astro-dist-${{ github.run_id }}
63+
restore-keys: ${{ runner.os }}-astro-dist-
64+
65+
- name: Install dependencies
66+
run: bun install --frozen-lockfile
67+
68+
- name: Fetch module data
69+
run: bun run scripts/fetch-data.ts
70+
env:
71+
GRAPHQL_TOKEN: ${{ secrets.GRAPHQL_TOKEN }}
72+
REPO: ${{ github.event.inputs.repo }}
73+
74+
- name: Build
75+
run: bun run build
76+
77+
- name: Save .cache directory
78+
if: ${{ github.event.inputs.repo }}
79+
uses: actions/cache/save@v4
80+
with:
81+
path: .cache
82+
key: ${{ runner.os }}-astro-cache-${{ github.run_id }}
83+
84+
- name: Save dist directory
85+
if: ${{ github.event.inputs.repo }}
86+
uses: actions/cache/save@v4
87+
with:
88+
path: dist
89+
key: ${{ runner.os }}-astro-dist-${{ github.run_id }}
90+
91+
- name: Upload artifact
92+
uses: actions/upload-pages-artifact@v3
93+
with:
94+
path: 'dist'
95+
96+
- name: Deploy to GitHub Pages
97+
id: deployment
98+
uses: actions/deploy-pages@v4

.github/workflows/tag.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Tag
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
repo:
6+
description: 'repo name'
7+
required: true
8+
release:
9+
description: 'release id'
10+
required: true
11+
zip:
12+
description: 'module zip url'
13+
required: true
14+
tag:
15+
description: 'tag name'
16+
required: true
17+
18+
run-name: Tag ${{ github.event.inputs.repo }}@${{ github.event.inputs.tag }}
19+
20+
jobs:
21+
update_tag:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- run: |
25+
wget -O module.zip '${{ github.event.inputs.zip }}'
26+
unzip -q module.zip
27+
if [ ! -f module.prop ]; then
28+
echo "Error: module.prop not found in zip file"
29+
exit 1
30+
fi
31+
VERCODE=$(grep '^versionCode=' module.prop | cut -d'=' -f2 | tr -d '\r\n ')
32+
VERNAME=$(grep '^version=' module.prop | cut -d'=' -f2 | tr -d '\r\n')
33+
if [ -z "$VERCODE" ] || [ -z "$VERNAME" ]; then
34+
echo "Error: versionCode or version not found in module.prop"
35+
exit 1
36+
fi
37+
VERNAME="${VERNAME// /_}"
38+
echo "Input tag: '${{ github.event.inputs.tag }}' -> Parsed: $VERCODE-$VERNAME"
39+
if [[ '${{ github.event.inputs.tag }}' == "$VERCODE-$VERNAME" ]]; then
40+
echo "Tag already correct, skipping..."
41+
exit 0
42+
fi
43+
mkdir test
44+
cd test
45+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
46+
git config --global user.name "github-actions[bot]"
47+
git init .
48+
git commit -m "$VERCODE-$VERNAME" --allow-empty
49+
git tag "$VERCODE-$VERNAME" -m "$VERCODE-$VERNAME" -f
50+
git remote add origin "https://${{ secrets.TAG_TOKEN }}@github.com/${{ github.event.inputs.repo }}.git"
51+
git push origin "$VERCODE-$VERNAME" -f
52+
curl -X PATCH -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.TAG_TOKEN }}" https://api.github.com/repos/${{ github.event.inputs.repo }}/releases/${{ github.event.inputs.release }} -d "{\"tag_name\":\"${VERCODE}-${VERNAME}\"}"

0 commit comments

Comments
 (0)