GitHub Actions Crawler ALL IN ONE at 2024-09-26 02:13:51 #3278
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
# 自动化名称 | |
name: Deploy Hexo Public To Pages | |
# 触发条件 | |
on: [push, workflow_dispatch] | |
# 设置环境 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
TZ: Asia/Shanghai | |
steps: | |
# check it to your workflow can access it | |
# from: https://github.com/actions/checkout | |
- name: Checkout Repository master branch | |
uses: actions/checkout@master | |
# from: https://github.com/actions/setup-node | |
- name: Setup Node.js 18.x | |
uses: actions/setup-node@master | |
with: | |
node-version: "18.x" | |
- name: 安装Hexo | |
run: | | |
npm install hexo-cli -g | |
- name: 设置Git信息 | |
run: | | |
git config --global user.name 'xlenco' | |
git config --global user.email '1043865083@qq.com' | |
- name: 安装依赖 | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
npm install --save | |
- name: 缓存 Hexo | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: node_modules | |
key: ${{runner.OS}}-${{hashFiles('**/package-lock.json')}} | |
- name: 生成静态文件 | |
run: | | |
hexo clean | |
hexo generate | |
# hexo algolia | |
- name: 部署 #此处master:master 指从本地的master分支提交到远程仓库的master分支,若远程仓库没有对应分支则新建一个。如有其他需要,可以根据自己的需求更改。 | |
run: | | |
cd ./public | |
git init | |
git add . | |
git commit -m "${{ github.event.head_commit.message }} $(date +"%Z %Y-%m-%d %A %H:%M:%S") Updated By Github Actions" | |
git push --force --quiet "https://${{ github.repository_owner }}:${{ secrets.GITHUBTOKEN }}@github.com/${{ github.repository_owner }}/${{ github.repository_owner }}.github.io.git" master:master | |
- name: Build And Deploy | |
id: builddeploy | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
repo_token: ${{ secrets.GITHUBTOKEN }} # Used for GitHub integrations (i.e. PR comments) | |
action: 'upload' | |
app_location: '/' | |
output_location: 'public' | |
app_build_command: 'npm run build ' |