add newpost58 #173
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博客持续集成 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检出仓库代码 | |
uses: actions/checkout@master | |
- name: 安装Node.js 14.x | |
uses: actions/setup-node@master | |
with: | |
node-version: "14.x" | |
- name: 安装Hexo依赖 | |
run: | | |
npm install hexo-cli -g | |
npm install | |
- name: 构建Hexo | |
run: | | |
hexo clean | |
hexo generate | |
- name: 安装腾讯云依赖 | |
run: | | |
sudo pip install coscmd==1.8.6.34 | |
- name: 配置腾讯云依赖 | |
env: | |
SECRET_ID: ${{ secrets.TCLOUD_API_ID }} | |
SECRET_KEY: ${{ secrets.TCLOUD_API_KEY }} | |
BUCKET: blog-1252906577 | |
REGION: ap-shanghai | |
run: | | |
coscmd config -a $SECRET_ID -s $SECRET_KEY -b $BUCKET -r $REGION | |
- name: 上传到腾讯云COS | |
run: | | |
coscmd upload -rfs --delete ./public/ / | |
- name: 配置Git部署私钥 | |
env: | |
HEXO_DEPLOY_PRIVATE_KEY: ${{ secrets.HEXO_DEPLOY_PRIVATE_KEY }} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$HEXO_DEPLOY_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
ssh-keyscan gitee.com >> ~/.ssh/known_hosts | |
- name: 配置Git信息 | |
run: | | |
git config --global user.name 'dr34-m' | |
git config --global user.email '1416814478@qq.com' | |
- name: 部署Hexo到Git | |
run: hexo deploy | |
- name: 打包压缩 | |
run: tar -zcvf release.tgz public | |
- name: 发布 Release | |
id: create_release | |
uses: actions/create-release@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.run_id }} | |
release_name: Release ${{ github.run_id }} | |
draft: false | |
prerelease: false | |
- name: 上传构建结果到 Release | |
id: upload-release-asset | |
uses: actions/upload-release-asset@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release.tgz | |
asset_name: release.tgz | |
asset_content_type: application/x-tgz |