Skip to content

Commit

Permalink
5
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Dec 10, 2024
1 parent 9a59c31 commit 9d07ea1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 66 deletions.
65 changes: 14 additions & 51 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ env:
GITHUB_ACTION_RUN_ID: ${{ github.run_id }}
GITHUB_ACTION_RUN_NUMBER: ${{ github.run_number }}

permissions:
contents: write
pull-requests: write
actions: write # 用于上传/下载 artifacts

jobs:
collect-data:
strategy:
Expand Down Expand Up @@ -60,56 +65,14 @@ jobs:
env UPDATE_EXPECT=1 cargo test
./target/release/moon_dashboard stat --file repos.txt
- name: Commit
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: Push changes
run: git fetch && git pull origin wip --rebase && git push origin wip

# 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: 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: 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
30 changes: 15 additions & 15 deletions src/auto_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ use crate::mooncakesio::get_all_mooncakes;

#[test]
fn gen_latest_list_with_version() {
let repos = std::fs::read_to_string("repos.txt").unwrap();
let parts: Vec<&str> = repos
.splitn(2, "# generated list to test mooncakes on mooncakes.io")
.collect();
// let repos = std::fs::read_to_string("repos.txt").unwrap();
// let parts: Vec<&str> = repos
// .splitn(2, "# generated list to test mooncakes on mooncakes.io")
// .collect();

let mut mooncakesio = String::new();
let db = get_all_mooncakes().unwrap();
for (name, versions) in db.db {
let latest_version = versions.last().unwrap();
mooncakesio.push_str(&format!("{} {}\n", name, latest_version));
}
// let mut mooncakesio = String::new();
// let db = get_all_mooncakes().unwrap();
// for (name, versions) in db.db {
// let latest_version = versions.last().unwrap();
// mooncakesio.push_str(&format!("{} {}\n", name, latest_version));
// }

let updated = format!(
"{}# generated list to test mooncakes on mooncakes.io\n{}",
parts[0], mooncakesio
);
std::fs::write("repos.txt", updated).unwrap();
// let updated = format!(
// "{}# generated list to test mooncakes on mooncakes.io\n{}",
// parts[0], mooncakesio
// );
// std::fs::write("repos.txt", updated).unwrap();
}

0 comments on commit 9d07ea1

Please sign in to comment.