Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
laishere committed Sep 29, 2024
0 parents commit 6c79ef7
Show file tree
Hide file tree
Showing 10 changed files with 2,241 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/generate-meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Generate Meta

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 3

- name: Checkout or create meta
run: git fetch --depth=3 origin meta && git checkout meta || git checkout -b meta

- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Merge main into meta
run: git merge --no-edit main

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Build project
env:
PURGE_CACHE_URL: ${{ secrets.PURGE_CACHE_URL }}
run: npm run build

- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add . && git commit -m "meta: ${{ github.event.head_commit.message }}" || true
git push origin meta
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.meta.local
.env
.local
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 laishere

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# My Blog Content

Only store the content and some scripts here. For website repository, please refer to [blog-website](https://github.com/laishere/blog-website).

## Setup

1. Clone template branch

```sh
git clone -b template https://github.com/laishere/blog.git
```

2. Rename as your main branch

```sh
git branch -M main
```

3. Install dependencies

```sh
npm install
```

## Test locally

1. Write some posts like this repository
2. Generate the posts meta locally

```sh
npm run dev
```

3. Update `VITE_LOCAL_CONTENT_DIR` in website project's `.env` and run the website locally
## Deploy
**Content**
1. Create a GitHub repository
2. Allow `write` permission for actions in repository settings
3. Push to remote
4. Check if the action is performed normally
**Website**
1. Generate a `PAT` for the website and set it in the website project `.env`
2. Deploy website
What's more, for purging cache of the website, please setup an environment variable for this repository: `PURGE_CACHE_URL=http://<YOUR-DOMAIN>/cache/purge/<YOUR-VITE_CACHE_PURGE_SECRET>`. You may want to set it in the local `.env` file and run `npm run dev` first to verify the URL is correct.

Loading

0 comments on commit 6c79ef7

Please sign in to comment.