-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaction.yml
More file actions
63 lines (62 loc) · 1.92 KB
/
action.yml
File metadata and controls
63 lines (62 loc) · 1.92 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
59
60
61
62
63
# https://www.freecodecamp.org/news/publishing-github-event-data-with-github-actions-and-pages/
# https://stackoverflow.com/questions/58597010/how-to-access-a-github-issue-comment-body-using-github-actions
# This is a basic workflow to help you get started with Actions
# https://github.com/maguowei/iaas/blob/d48834c18b66ae0f3ae32e5e62a6811dfddadcb2/.github/workflows/iaas.yml
name: issue2post
description: "Turn issues into markdown file"
branding:
icon: "archive"
color: "green"
inputs:
branch:
description: "Target branch name to push the markdownfile"
required: true
default: "master"
dir:
description: "the posts dir"
required: true
default: "_posts"
GITHUB_TOKEN:
description: "secrets.GITHUB_TOKEN"
required: true
created_at:
description: "github.event.issue.created_at"
required: true
title:
description: "github.event.issue.title"
required: true
body:
description: "github.event.issue.body"
required: true
actor:
description: "github.actor"
required: true
runs:
using: "composite"
steps:
- id: generate-markdown-file
name: Turn comment into file
shell: bash
run: |
DATE="${{ inputs.created_at }}"
mkdir -p ${{ inputs.dir }}
cat <<'EOF' > _posts/"${DATE:0:10}-${{ github.event.issue.title }}".md
---
layout: post
title: ${{ inputs.title }}
date: ${{ inputs.created_at }}
---
${{ inputs.body }}
EOF
- name: Push changes to repo
shell: bash
run: |
REMOTE=https://${{ inputs.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git config user.email "${{ inputs.actor }}@users.noreply.github.com"
git config user.name "${{ inputs.actor }}"
git pull ${REMOTE}
git checkout ${{ inputs.branch }}
git add .
git status
git commit -am "Add new comment"
git push ${REMOTE} ${{ inputs.branch }}