这个问题我问了chatgpt:
问题1
生成一段github的workflows配置文档,当有新issue的时候,自动将issue的内容同步到该GitHub项目的blog分支的content/post文件夹中的新Markdown文件中。文件名为"{YYYYMMDD}-{Title}.md",其中{YYYYMMDD}为issue的日期,"{Title}"为issue的标题。文件开头加上
---
title:
data:
lastmod:
draft: false
tags:
---
它给我回复了一个GitHub Workflows 配置文档
name: Sync Issue to Blog
on:
issues:
types: [opened, edited]
jobs:
sync-issue-to-blog:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "latest"
- name: Create Blog Post
id: create_post
run: |
issue_title=$(echo "${
{ github.event.issue.title }}" | sed 's/[[:space:]]/-/g')
issue_date=$(echo "${
{ github.event.issue.created_at }}" | cut -c1-10 | sed 's/-//g')
post_path="content/post/${issue_date}-${issue_title}.md"
post_date=$(echo "${
{ github.event.issue.created_at }}" | cut -c1-10)
post_title=$(echo "${
{ github.event.issue.title }}" | sed 's/"/\\"/g')
post_body=$(echo "${
{ github.event.issue.body }}" | sed 's/"/\\"/g')
echo "---" > "${post_path}"
echo "title: \"${post_title}\"" >> "${post_path}"
echo "date: \"${post_date}\"" >> "${post_path}"
echo "lastmod: \"${post_date}\"" >> "${post_path}"
echo "draft: false" >> "${post_path}"
echo "tags:" >> "${post_path}"
echo "---" >> "${post_path}"
echo "${post_body}" >> "${post_path}"
- name: Commit and Push Changes
run