Skip to content
Merged

Pages #213

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build & Publish Wallpapers (GitHub Pages)

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: write

concurrency:
group: pages-publish
cancel-in-progress: true

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Build bundle
run: node build-wallpapers.js

- name: Publish to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: dist
publish_branch: gh-pages
force_orphan: true
27 changes: 27 additions & 0 deletions build-wallpapers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require('fs');
const path = require('path');

const OUT_DIR = path.join(__dirname, 'dist');
fs.mkdirSync(OUT_DIR, { recursive: true });

const jsonsDir = path.join(__dirname, 'jsons');
const wallpapersFile = path.join(OUT_DIR, 'wallpapers.json');

const wallpapersData = {};

const jsonFiles = fs.readdirSync(jsonsDir)
.filter(file => file.endsWith('.json'))
.sort();

const wallpapers = [];
for (const file of jsonFiles) {
const filePath = path.join(jsonsDir, file);
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
wallpapers.push(data);
}

wallpapersData.wallpapers = wallpapers;

fs.writeFileSync(wallpapersFile, JSON.stringify(wallpapersData, null, 2) + '\n', 'utf8');

console.log(`Successfully merged ${wallpapers.length} wallpapers`);
Loading