-
Notifications
You must be signed in to change notification settings - Fork 5
58 lines (50 loc) · 2.47 KB
/
Copy pathsave-article.yml
File metadata and controls
58 lines (50 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Generate Markdown
on:
issues:
types:
- labeled
- edited
jobs:
generate-markdown:
if: github.event.issue.state == 'open' && contains(github.event.issue.labels.*.name, 'Article')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- id: issue-parser
uses: stefanbuck/github-issue-parser@v3
with:
template-path: ".github/ISSUE_TEMPLATE/new-article.yml"
- name: Generate Markdown file
env:
GH_TOKEN: ${{ github.token }}
FILE_NAME: ${{ steps.issue-parser.outputs.issueparser_file_name }}
CATEGORY: ${{ steps.issue-parser.outputs.issueparser_category }}
THUMBNAIL: ${{ steps.issue-parser.outputs.issueparser_thumbnail }}
run: |
FILE_PATH="Article/$CATEGORY/$FILE_NAME"
cat <<EOF > "_posts/${FILE_PATH}.md"
---
title: "${{ github.event.issue.title }}"
date: ${{ steps.issue-parser.outputs.issueparser_date || github.event.issue.created_at }}
updated: ${{ steps.issue-parser.outputs.issueparser_updated }}
categories: [Article, $CATEGORY]
tags: [${{ steps.issue-parser.outputs.issueparser_tags }}]
authors: [${{ steps.issue-parser.outputs.issueparser_authors }}]
original: ${{ steps.issue-parser.outputs.issueparser_original }}
toc: true
thumbnail: $(echo $THUMBNAIL | grep -oE 'https?://[^ \)]+' | head -n 1)
---
${{ steps.issue-parser.outputs.issueparser_content }}
EOF
POST_URL=$(echo "https://fcc-cd.dev/$FILE_PATH" | tr '[:upper:]' '[:lower:]')
COMMENT_BODY="After the linked PR merged, the article will be posted at: $POST_URL"
gh issue comment ${{ github.event.issue.number }} --body "$COMMENT_BODY"
- uses: peter-evans/create-pull-request@v7
with:
title: "[add] ${{ github.event.issue.title }} article"
body: "closes #${{ github.event.issue.number }}"
author: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>"