Skip to content

Commit

Permalink
Use actions/upload-pages-artifact to deploy instead of gh-pages branch
Browse files Browse the repository at this point in the history
  • Loading branch information
poiru committed Aug 7, 2024
1 parent ddb9320 commit a00ca29
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 170 deletions.
48 changes: 14 additions & 34 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy
name: Deploy Pages

on:
push:
Expand All @@ -9,47 +9,27 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Clone repo
uses: actions/checkout@v1

- name: Setup SSH deploy key
run: |
ssh-agent >| ~/.ssh-agent.env
source ~/.ssh-agent.env >| /dev/null
mkdir -p ~/.ssh
echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts
KEY_FILE=~/.ssh/deploy_key
echo "${DEPLOY_SSH_PRIVATE_KEY}" | base64 --decode > $KEY_FILE
chmod 600 $KEY_FILE
ssh-add $KEY_FILE
env:
DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
shell: bash

- name: Cache node_modules
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Cache _ghpages.git
uses: actions/cache@v1
with:
path: _ghpages.git
key: node-modules-${{ runner.os }}-${{ hashFiles('**/deploy.sh') }}

- name: Deploy
- name: Build
run: |
git config --global user.email "[email protected]"
git config --global user.name "Rainmeter Bot"
npm install
source ~/.ssh-agent.env >| /dev/null
npm run deploy
npm run build
shell: bash

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*debug.log
_generated
public/
_generated/
node_modules/
_ghpages.git
.deploy_git
db.json
node_modules
yarn-error.log
9 changes: 1 addition & 8 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permalink_defaults:

# Directory
source_dir: source
public_dir: _generated
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
Expand Down Expand Up @@ -56,10 +56,3 @@ pagination_dir: page

# Extensions
theme: rainmeter-www

# Deployment
deploy:
type: git
message: "Update: {{ now('YYYY-MM-DD HH:mm:ss') }}"
repo: https://github.com/rainmeter/rainmeter-www.git
branch: gh-pages
28 changes: 1 addition & 27 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,9 @@ set -o errexit
set -o pipefail
set -o nounset

# init script
PUBLIC_DIR=_generated
GHPAGES_DIR=_ghpages.git
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
YELLOW='\033[1;33m'
WHITE='\033[1;37m'
SET='\033[0m'
pushd "$SCRIPT_DIR"

echo -e "${YELLOW}INFO:${WHITE} Starting build script...${SET}"
sleep 1

# Clean up old files
echo -e "${YELLOW}1/3:${WHITE} Clean up old files${SET}"
if [ -d "$PUBLIC_DIR" ]; then
rm -rv $PUBLIC_DIR
else
echo -e "INFO $PUBLIC_DIR doesn't exist, continuing..."
fi
hexo clean

# Generate blog
echo -e "${YELLOW}2/3:${WHITE} Generate blog files${SET}"
hexo generate

# Run PostCSS
echo -e "${YELLOW}3/3:${WHITE} Run PostCSS${SET}"
cd $PUBLIC_DIR
postcss css/style.css --replace --verbose

echo -e "${YELLOW}INFO:${WHITE} Script finished, will close in 5 seconds...${SET}"
sleep 5
(cd ./public && postcss css/style.css --replace)
34 changes: 0 additions & 34 deletions clean.sh

This file was deleted.

63 changes: 0 additions & 63 deletions deploy.sh

This file was deleted.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"start": "hexo server --log",
"generate": "hexo generate",
"build": "./build.sh",
"deploy": "./deploy.sh",
"clean": "./clean.sh"
"clean": "hexo clean"
},
"dependencies": {
"bootstrap": "4.6.2",
Expand Down

0 comments on commit a00ca29

Please sign in to comment.