-
Notifications
You must be signed in to change notification settings - Fork 5
55 lines (53 loc) · 1.7 KB
/
create-draft.yaml
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
name: "[Reusable workflows] create draft and pull from hatenablog"
on:
workflow_call:
inputs:
title:
required: true
type: string
draft:
default: true
type: boolean
BLOG_DOMAIN:
required: true
type: string
secrets:
OWNER_API_KEY:
required: true
jobs:
post_draft_and_pull_from_hatenablog:
name: create draft and pull from hatenablog
runs-on: ubuntu-latest
env:
BLOGSYNC_PASSWORD: ${{ secrets.OWNER_API_KEY }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup
uses: hatena/hatenablog-workflows/.github/actions/setup@v1
- name: setup draft
run: |
yq --front-matter="process" ".Title=strenv(TITLE)" draft.template > draft
env:
TITLE: ${{ inputs.title }}
- name: set blog domain
id: set-domain
run: |
domain=${{ inputs.BLOG_DOMAIN }}
echo "BLOG_DOMAIN=$(echo $domain | tr -d '\n\r ')" >> "$GITHUB_OUTPUT"
- name: post draft to hatenablog
id: post-draft
run: |
entry_path=$(blogsync post --draft ${{ steps.set-domain.outputs.BLOG_DOMAIN }} < 'draft')
echo "ENTRY_PATH=$entry_path" >> "$GITHUB_OUTPUT"
- name: fetch entry
run: |
blogsync fetch ${{ steps.post-draft.outputs.ENTRY_PATH }}
- name: pull draft by title
uses: hatena/hatenablog-workflows/.github/actions/create-draft-pull-request@v1
with:
title: ${{ inputs.title }}
draft: ${{ inputs.draft }}
BLOG_DOMAIN: ${{ steps.set-domain.outputs.BLOG_DOMAIN }}
ENTRY_PATH: ${{ steps.post-draft.outputs.ENTRY_PATH }}