-
Notifications
You must be signed in to change notification settings - Fork 8
47 lines (45 loc) · 1.63 KB
/
push-draft.yaml
File metadata and controls
47 lines (45 loc) · 1.63 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
name: "[Reusable workflows] push draft to hatena blog"
on:
workflow_call:
inputs:
runner:
required: false
default: ubuntu-latest
type: string
secrets:
OWNER_API_KEY:
required: true
jobs:
upload-images:
uses: hatena/hatenablog-workflows/.github/workflows/upload-images.yaml@6c7e0917c0ba2b68ccedc5710fd810805c91fa5f
with:
runner: ${{ inputs.runner }}
secrets:
OWNER_API_KEY: ${{ secrets.OWNER_API_KEY }}
push-draft:
if: always()
needs: upload-images
runs-on: ${{ inputs.runner }}
env:
BLOGSYNC_PASSWORD: ${{ secrets.OWNER_API_KEY }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ needs.upload-images.result == 'success' && needs.upload-images.outputs.revision || '' }}
fetch-depth: 0
- name: setup
uses: hatena/hatenablog-workflows/.github/actions/setup@6c7e0917c0ba2b68ccedc5710fd810805c91fa5f
- name: Get changed draft files
id: changed-draft-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: draft_entries/**/*.md
- name: push only draft entry
run: |
for file in ${{ steps.changed-draft-files.outputs.all_changed_files }}; do
draft=$(yq --front-matter=extract 'select(.Draft == true)' "$file")
editurl=$(yq --front-matter=extract 'select(.EditURL == "https://blog.hatena.ne.jp/*")' "$file")
if [[ -n "$draft" ]] && [[ -n "$editurl" ]]; then
blogsync push "$file"
fi
done