Skip to content

Commit

Permalink
feat: ✨ gitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Dec 25, 2024
1 parent 148a2fb commit 08ac9c8
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Auto merge main into git-pages

on:
push:
branches:
- main
pull_request:
types: [closed]

permissions:
contents: write

jobs:
sync:
if: github.event.pull_request.merged == true || github.event_name == 'push'
runs-on: ubuntu-latest

steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Add git-pages remote
run: |
git remote add git-pages https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Fetch git-pages branch
run: git fetch origin git-pages:git-pages

- name: Checkout git-page branch
run: git checkout git-pages

- name: Merge main into git-pages
run: |
git merge main --no-ff -m "feat: ✨ Auto-merge main into git-pages"
- name: Push changes to git-pages
run: git push origin git-pages

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
event-type: git-pages-deploy
57 changes: 57 additions & 0 deletions .github/workflows/git-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Automatic deployment to GitHub Pages

on:
push:
branches:
- git-pages
repository_dispatch:
types: [git-pages-deploy]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'push' && github.ref || 'git-pages' }}
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: pnpm

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .github/workflows/release.yml

name: Release

permissions:
contents: write

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set node
uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: lts/*

- run: npx changelogithub # or [email protected] if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 08ac9c8

Please sign in to comment.