-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (118 loc) · 4.35 KB
/
jobs.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on:
push:
branches: main
pull_request:
branches: main
schedule:
- cron: '0 18 * * *' # 02:00 AM UTC+8
env:
CARGO_TERM_COLOR: always
GITHUB_ACTION_RUN_ID: ${{ github.run_id }}
GITHUB_ACTION_RUN_NUMBER: ${{ github.run_number }}
permissions:
contents: write
pull-requests: write
actions: write
jobs:
collect-data:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/[email protected]
with:
components: rustfmt, clippy
- name: Cargo cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
path: ~/.cargo/registry
- name: install MoonBit(Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> $GITHUB_PATH
- name: install MoonBit(Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
"C:\Users\runneradmin\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Version
run: moon version --all
- name: moon update
run: |
moon update
- name: Build
run: |
cargo build --release
env UPDATE_EXPECT=1 cargo test
./target/release/moon_dashboard stat --file repos.txt
- name: Upload data
uses: actions/upload-artifact@v4
with:
name: data-${{ matrix.os }}
path: |
${{ matrix.os == 'macos-latest' && './webapp/public/mac/latest_data.jsonl.gz' ||
matrix.os == 'windows-latest' && './webapp/public/windows/latest_data.jsonl.gz' ||
'./webapp/public/linux/latest_data.jsonl.gz' }}
if-no-files-found: error
- name: Commit(Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add ./webapp/public/*
git add ./repos.txt
git commit -m "Update data for ${{ matrix.os }} at $(date '+%Y-%m-%d %H:%M:%S')" || echo "No changes to commit"
- name: Commit(Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add ./webapp/public/*
git commit -m "Update data for ${{ matrix.os }} at $(date '+%Y-%m-%d %H:%M:%S')" || echo "No changes to commit"
git stash
- name: Push changes
run: git fetch && git pull --rebase && git push
deploy:
needs: collect-data
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Pull latest
run: git fetch && git pull --rebase
- name: Check commit
run: git log -5
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install pnpm
run: npm install -g pnpm
- name: pnpm install
run: pnpm install
working-directory: ./webapp
- name: pnpm run build
run: |
pnpm run build
sed -i '' 's|="/assets|="/moon-build-dashboard/assets|g' ./dist/index.html
sed -i '' 's|"/linux/latest_data.jsonl.gz"|"/moon-build-dashboard/linux/latest_data.jsonl.gz"|g' ./dist/assets/*.js
sed -i '' 's|"/windows/latest_data.jsonl.gz"|"/moon-build-dashboard/windows/latest_data.jsonl.gz"|g' ./dist/assets/*.js
sed -i '' 's|"/mac/latest_data.jsonl.gz"|"/moon-build-dashboard/mac/latest_data.jsonl.gz"|g' ./dist/assets/*.js
working-directory: ./webapp
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./webapp/dist
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
force_orphan: true