Skip to content

Try fix deployment #101

Try fix deployment

Try fix deployment #101

Workflow file for this run

name: Publish to gh-pages
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm test
- run: npm run build:cos
- name: Install coscmd
run: sudo pip install coscmd
- name: Configure coscmd
run: coscmd config -a ${{ secrets.SecretId }} -s $${{ secrets.SecretKey }} -b $${{ vars.BUCKET }} -r $${{ vars.REGION }}
- name: Publish static files to COS
run: |
cd ./build/
coscmd upload -rs --delete -f ./ / --ignore index.html
rm -rf !(index.html)
- name: Publish to GitHub Pages
run: |
# Create a temporary directory
export temp_dir=`mktemp -d -p ~`
(
# Preserve .git
mkdir $temp_dir/temp
mv .git $temp_dir/temp
cd $temp_dir/temp
# Switch branch
git fetch
git checkout gh-pages
git reset --hard gh-pages
)
(
# Move .git
mv $temp_dir/temp/.git $temp_dir
rm -rf $temp_dir/temp
mv build/* $temp_dir
mv LICENSE $temp_dir
# Go to the temporary directory
cd $temp_dir
# Set commit identity
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
# Publish
git add .
if [ -n "$(git status --porcelain)" ]; then
git commit -m "Published at `TZ='Asia/Hong_Kong' date --rfc-3339=seconds`"
git push -f origin gh-pages
fi
)