Skip to content

Commit

Permalink
Try fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaka14732 committed Sep 4, 2024
1 parent 7e48039 commit 9506ec2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 56 deletions.
82 changes: 27 additions & 55 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

jobs:
deploy:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -15,59 +15,31 @@ jobs:
node-version: 22
- run: npm ci
- run: npm test
# FIXME CORS broken, building non-COS version for now
#- run: npm run build:cos
- run: npm run build
# FIXME CORS broken, deploying everything on GH Pages for now
#- name: Install coscmd
# run: sudo pip install coscmd
#- name: Configure coscmd
# env:
# SECRET_ID: ${{ secrets.SecretId }}
# SECRET_KEY: ${{ secrets.SecretKey }}
# BUCKET: ${{ secrets.Bucket }}
# REGION: ${{ secrets.Region }}
# run: coscmd config -a $SECRET_ID -s $SECRET_KEY -b $BUCKET -r $REGION
#- name: Publish static files to COS
# run: |
# cd ./build/
# coscmd upload -rs --delete -f ./ / --ignore index.html
# rm -rf assets
- name: Publish to GitHub Pages
- 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: |
# 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]"
cd ./build/
coscmd upload -rs --delete -f ./ / --ignore index.html
find . -mindepth 1 ! -name index.html -exec rm -rf {} +
- name: Upload Artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./build

# 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
)
deploy:
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion vite.cos.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeConfig } from "./vite.config";

// Same as base config but prefix each asset path in index.html with this location
export default makeConfig("https://qieyun-autoderiver-1305783649.file.myqcloud.com/");
export default makeConfig("https://autoderiver-1305783649.cos.accelerate.myqcloud.com/");

0 comments on commit 9506ec2

Please sign in to comment.