-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
85 lines (76 loc) · 2.79 KB
/
action.yml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: "GitHub to Qiita"
description: "Publish development articles to Qiita automatically"
author: "noraworld"
branding:
icon: search
color: green
inputs:
dir:
description: "Specify a directory in which files you want to track and publish to Qiita"
required: true
qiita_access_token:
description: "Specify your Qiita access token"
required: true
mapping_filepath:
description: "Specify any file path in which you want to put the mapping file"
required: false
default: "mapping.txt"
strict:
description: "Specify whether the strict mode is on or off"
required: false
default: false
added_files:
description: "Get added files"
modified_files:
description: "Get modified files"
deleted_files:
description: "Get deleted files"
runs:
using: "composite"
steps:
- name: Enable Git operation
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.1"
- name: Install RubyGems
run: bundle install --gemfile=$GITHUB_ACTION_PATH/Gemfile
shell: sh
env:
GITHUB_ACTION_PATH: ${{ github.action_path }}
- id: get-added-files
name: Get added files
run: echo "::set-output name=files::$(git diff --name-only --diff-filter=A ${{ github.event.before }} ${{ github.sha }} | egrep "^${{ inputs.dir }}/" | xargs)"
shell: sh
- id: get-modified-files
name: Get modified files
run: echo "::set-output name=files::$(git diff --name-only --diff-filter=M ${{ github.event.before }} ${{ github.sha }} | egrep "^${{ inputs.dir }}/" | xargs)"
shell: sh
- id: get-deleted-files
name: Get deleted files
run: echo "::set-output name=files::$(git diff --name-only --diff-filter=D ${{ github.event.before }} ${{ github.sha }} | egrep "^${{ inputs.dir }}/" | xargs)"
shell: sh
- name: Publish to Qiita
run: ruby $GITHUB_ACTION_PATH/main.rb
shell: sh
env:
QIITA_ACCESS_TOKEN: ${{ inputs.qiita_access_token }}
MAPPING_FILEPATH: ${{ inputs.mapping_filepath }}
STRICT: ${{ inputs.strict }}
GITHUB_ACTION_PATH: ${{ github.action_path }}
ADDED_FILES: ${{ steps.get-added-files.outputs.files }}
MODIFIED_FILES: ${{ steps.get-modified-files.outputs.files }}
DELETED_FILES: ${{ steps.get-deleted-files.outputs.files }}
- name: Update mapping file
# https://github.com/actions/checkout/tree/2d1c1198e79c30cca5c3957b1e3b65ce95b5356e#push-a-commit-using-the-built-in-token
run: |
if [ -n "$(git status --porcelain)" ]; then
git config user.name github-actions
git config user.email [email protected]
git commit -am "Update mapping file"
git push
fi
shell: sh