Created
November 8, 2019 17:04
-
-
Save yrpang/82a4a546c737d44cd58ca56595e3c335 to your computer and use it in GitHub Desktop.
github-actions-hexo
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: Hexo Build and Deploy | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12] | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
submodules: recursive | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: setup key | |
env: | |
ACTION_KEY: ${{secrets.ACTION_KEY}} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$ACTION_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
git config --global user.name 'YOUR_NAME' #注意替换为自己的 | |
git config --global user.email 'YOUR_EMAIL' #注意替换为自己的 | |
- name: Cache node modules | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{ runner.OS }}-${{ hashFiles('**/package-lock.json') }} | |
- name: setup hexo env | |
run: | | |
sudo npm i -g hexo-cli | |
npm install | |
- name: generate | |
run: | | |
hexo g | |
hexo d | |
- name: Purge cache in CloudFlare | |
env: | |
CLOUDFLARE_API_KEY: ${{secrets.CLOUDFLARE_API_KEY}} | |
USER_NAME: ${{secrets.USER_NAME}} | |
run: | | |
curl -X POST "https://api.cloudflare.com/client/v4/zones/7dc166628e3719ffe9d00a0f235e6576/purge_cache" \ | |
-H "X-Auth-Email: $USER_NAME" \ | |
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \ | |
-H "Content-Type: application/json" \ | |
--data '{"files":["FILES"]}' #替换为要刷新的缓存 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment