更新hexo版本 #164
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: BLOG CI | |
on: | |
push: | |
branches: [hexo] | |
pull_request: | |
branches: [hexo] | |
env: | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.x] | |
steps: | |
- name: Checkout Codes | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install Hexo Dependencies | |
run: | | |
npm install hexo-cli -g | |
npm install | |
npm ls --depth 0 | |
- name: Generate Files | |
run: | | |
echo "generate files" | |
hexo clean && hexo douban && hexo generate | |
hexo config theme cactus && hexo config url https://imtzz.com/cactus && hexo config public_dir public/cactus && hexo config language en | |
hexo generate | |
- name: Git Repository Update | |
run: | | |
echo "git repo update" | |
cd ./public | |
ls -a | |
echo '-------------------' | |
head -n 10 index.html | |
echo '-------------------' | |
git init | |
git add . | |
git config --global user.name "Github Action" | |
git config --global user.email ${{secrets.EMAIL}} | |
git commit -m "Github Action Auto Builder at `date +"%Y-%m-%d %H:%M"`" | |
git push --force "https://${{secrets.GITHUBTOKEN}}@${GH_REF}" master:master | |
git push --force "https://${{secrets.CODING_TOKEN_NAME}}:${{secrets.CODINGTOKEN}}@${Coding}" master:master | |
env: | |
GH_REF: github.com/tzzs/tzzs.github.io.git | |
Coding: e.coding.net/imtzz/Pages.git | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${KEY}" > ~/.ssh/deploy.key | |
chmod 600 ~/.ssh/deploy.key | |
cat >> ~/.ssh/config <<END | |
Host server | |
HostName $IP | |
User $USERNAME | |
IdentityFile ~/.ssh/deploy.key | |
StrictHostKeyChecking no | |
END | |
env: | |
IP: ${{secrets.SERVER_IP}} | |
USERNAME: ${{secrets.SERVER_USERNAME}} | |
KEY: ${{secrets.SERVER_PRIVATE_KEY}} | |
- name: Checkout Codes | |
uses: actions/checkout@v2 | |
- name: Deploy to Server | |
run: | | |
echo "Deploy to Server..." | |
ls | |
echo "[test pwd]" | |
ssh server "pwd" | |
echo "[exec dpeloy.sh]" | |
ssh server < deploy.sh > /dev/null 2>&1 |