v0.136.0 #199
Workflow file for this run
This file contains hidden or 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 run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | |
# name: Publish to AliyunOSS | |
# on: | |
# push: | |
# branches: | |
# - "deploy" | |
# jobs: | |
# build: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v2 | |
# - uses: actions/setup-node@v2 | |
# with: | |
# node-version: 14 | |
# - run: yarn install | |
# - run: yarn run build | |
# - name: Upload AliyunOSS | |
# uses: fangbinwei/aliyun-oss-website-action@v1 | |
# with: | |
# accessKeyId: ${{ secrets.ACCESS_KEY_ID }} | |
# accessKeySecret: ${{ secrets.ACCESS_KEY_SECRET }} | |
# bucket: "yaklang-io" | |
# endpoint: "oss-accelerate-overseas.aliyuncs.com" | |
# folder: "./build" | |
# 新Github-Ci | |
name: Yarn Build and Deploy CI | |
on: | |
push: | |
tags: | |
- "v*" | |
paths: | |
- '.github/workflows/publish-to-oss.yml' | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: '部署环境' | |
required: true | |
default: 'production' | |
type: choice | |
options: | |
- production | |
- staging | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# retry-on-error: true | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.20.0" | |
# 缓存 node_modules | |
- name: Cache Node Modules | |
uses: actions/cache@v3 | |
id: node-cache | |
with: | |
path: | | |
node_modules | |
**/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ hashFiles('**/package.json') }}- | |
${{ runner.os }}-node- | |
# 打包 | |
- name: Install Dependencies | |
if: steps.node-cache.outputs.cache-hit != 'true' | |
run: yarn install | |
- name: Save Node Modules Cache | |
if: steps.node-cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
path: | | |
node_modules | |
**/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-${{ hashFiles('yarn.lock') }} | |
- name: Build | |
run: yarn run build | |
- name: Pack Out File | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }} | |
run: tar -zcvf out.tgz build | |
# 配置 Git | |
- name: Setup Git | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }} | |
run: | | |
git config --global user.name "v1ll4n" | |
git config --global user.email "[email protected]" | |
# 部署到 yaklang.io | |
- name: Deploy to yaklang.io | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
GIT_USER: v1ll4n | |
GIT_PASS: ${{ secrets.GH_TOKEN }} | |
run: yarn deploy | |
# 部署到服务器 | |
- name: Upload Build Files via SSH | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }} | |
uses: easingthemes/[email protected] | |
with: | |
REMOTE_USER: 'root' | |
REMOTE_HOST: '${{ secrets.ONLINE_HOST }}' | |
SSH_PRIVATE_KEY: ${{ secrets.ONLINE_PRIV_KEY }} | |
ARGS: "-avzr --delete" | |
SOURCE: "out.tgz" | |
TARGET: '/root/yaklang-io/' | |
- name: Extract and Cleanup on Server | |
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }} | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.ONLINE_HOST }} | |
username: 'root' | |
key: ${{ secrets.ONLINE_PRIV_KEY }} | |
script: | | |
cd /root/yaklang-io/ | |
tar zxvf out.tgz | |
rm -rf out.tgz | |