Skip to content

get deployed name

get deployed name #5

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- master # 这里表示push到master分支就会触发流程,请根据实际情况修改
pull_request:
branches:
- master
permissions:
contents: write
env:
TZ: Asia/Shanghai
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 这是github官方的一个action,用于clone该仓库的源码到工作流中
- name: Checkout 🛎️
uses: actions/checkout@v4
# 安装node
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.17.0
cache: npm
- name: Install and Build
run: |
npm install # 使用 npm 安装依赖
npm run build # 使用 npm 运行构建命令
- name: 获取当前时间
id: time
shell: bash
run: echo "time=$(date +'%Y-%m-%d %H:%M:%S')" >> ${GITHUB_OUTPUT}
# 部署
- name: Deploy 🚀 # 部署
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # 部署后提交到哪个分支
folder: docs # 存放 build 后产物的目录
commit-message: 发布于:${{ steps.time.outputs.time }} # 提交信息
# token: ${{ secrets.ACCESS_TOKEN }} # token 同仓库可以不填
# repository-name: kongxiangyiren/kongxiangyiren.github.io # 要部署的仓库,请根据实际情况修改为用户名/仓库名,同仓库可以不填
# 显示部署成功的 GitHub Pages 地址
- name: Show GitHub Pages URL
run: |
REPO_URL="https://${GITHUB_REPOSITORY_OWNER}.github.io/${GITHUB_REPOSITORY_NAME}/"
echo "Deployed to $REPO_URL"
env:
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} # 用户名
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }} # 仓库名