Last active
May 26, 2022 09:22
-
-
Save PDPENG/cc6620701001f89b6d30cd979be27ece to your computer and use it in GitHub Desktop.
HexoAutoDeployOnGitHubActions
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
# Action's Name | |
name: AutoDeploy | |
on: | |
# Triggering Condition 1 Main Branch Performs The Task After Receiving Push | |
push: | |
branches: | |
- master | |
# Triggering Condition 2 Manual Button | |
workflow_dispatch: | |
# Putting Environment Variables Here You Need To Replace It With Your Own | |
env: | |
# After Hexo Compiles Use This Git User To Deploy To The Github Warehouse | |
GIT_USER: PDPENG | |
# After Hexo Compiles Use This Git Mailbox To Deploy To The Github Warehouse | |
GIT_EMAIL: jason.peng.code@gmail.com | |
# The Git Hub Warehouse To Be Deployed After Hexo Compiles | |
GIT_DEPLOY_REPO: PDPENG/pdpeng.github.io | |
# Hexo Compiles The Branch To Deploy After Compilation | |
GIT_DEPLOY_BRANCH: master | |
# After Hexo Compiles Use This Gitee User To Deploy To The Gitee Warehouse | |
GITEE_USER: Coder-Jason | |
# The Gitee Warehouse To Be Deployed After Hexo Compiles | |
GITEE_DEPLOY_REPO: Coder-Jason/Coder-Jason | |
# Hexo Compiles The Branch To Deploy After Compilation | |
GITEE_DEPLOY_BRANCH: master | |
# Pay Attention To Replacing Your Github Source Warehouse Address | |
GIT_SOURCE_REPO: git@github.com:PDPENG/pdpeng.github.io.git | |
# Pay Attention To Replacement To Your Gitee Target Warehouse Address | |
GITEE_DESTINATION_REPO: git@gitee.com:Coder-Jason/coder-jason.git | |
jobs: | |
build: | |
name: Build on node ${{ matrix.node_version }} and ${{ matrix.os }} | |
runs-on: ubuntu-latest | |
if: github.event.repository.owner.id == github.event.sender.id | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
node_version: [16.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Checkout deploy repo | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ env.GIT_DEPLOY_REPO }} | |
ref: ${{ env.GIT_DEPLOY_BRANCH }} | |
path: .deploy_git | |
- name: Use Node.js ${{ matrix.node_version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node_version }} | |
- name: Configuration environment | |
env: | |
HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}} | |
run: | | |
sudo timedatectl set-timezone "Asia/Shanghai" | |
mkdir -p ~/.ssh/ | |
echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts | |
ssh-keyscan -t rsa gitee.com >> ~/.ssh/known_hosts | |
git config --global user.name $GIT_USER | |
git config --global user.email $GIT_EMAIL | |
- name: Install dependencies | |
run: | | |
npm install hexo-cli -g | |
# Install According To The Components You Installed | |
npm install - gulp gulp-uglify hexo hexo-deployer-git hexo-generator-archive hexo-generator-category hexo-generator-feed hexo-generator-index hexo-generator-search hexo-generator-searchdb hexo-generator-sitemap hexo-generator-tag hexo-leancloud-counter-security hexo-renderer-ejs hexo-renderer-marked hexo-renderer-pug hexo-renderer-stylus hexo-server hexo-tag-cloud hexo-word-counter readable-stream uglify-es --save | |
- name: Deploy hexo | |
run: | | |
npm run deploy | |
# The Following Is The Release To Gitee | |
- name: Sync to Gitee | |
uses: wearerequired/git-mirror-action@master | |
env: | |
# Using Hexo Deploy Pri Directly | |
SSH_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_PRI }} | |
with: | |
# GitHub Source Warehouse Address | |
source-repo: ${{ env.GIT_SOURCE_REPO }} | |
# Gitee Target Warehouse Address | |
destination-repo: ${{ env.GITEE_DESTINATION_REPO }} | |
- name: Build Gitee Pages | |
uses: yanglbme/gitee-pages-action@main | |
with: | |
# Your Gitee Username | |
gitee-username: ${{ env.GITEE_USER }} | |
# Note At Settings Secrets Configuration Gitee Password | |
gitee-password: ${{ secrets.GITEE_PASSWORD }} | |
# Your Gitee Warehouse The Warehouse Name Is Strictly Distinguished Please Fill In It Accurately Otherwise There Will Be An Error | |
gitee-repo: ${{ env.GITEE_DEPLOY_REPO }} | |
# To Deploy Branches The Default Is Master If It Is Other Branches You Need To Specify The Specified Branch Must Exist | |
branch: ${{ env.GITEE_DEPLOY_BRANCH }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment