-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
77 lines (70 loc) · 2.18 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
name: "Merge on Merge"
description: "Github Action to combine JSON files while preventing PR conflicts"
inputs:
github_token:
description: "Github Token"
default: "${{ github.token }}"
required: false
mode:
description: "preview: Post preview as pull request comment, commit: Commit & Push"
required: false
default: "preview"
input_path:
description: "JSON input folder"
required: false
default: "input"
base:
description: "base"
required: false
default: "out.json"
merge_json_path:
description: "JSON traverse path to merge the input in, use dot notation"
required: false
default: "json.path.to.merge"
output:
description: "output"
required: false
default: "out.json"
processed_path:
description: "processed_path"
required: false
default: "processed"
repo:
description: "repo"
required: false
runs:
using: "composite"
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- shell: bash
run: ruby ${{ github.action_path }}/merge_on_merge.rb "${{ inputs.input_path }}" "${{ inputs.base }}" "${{ inputs.merge_json_path }}" "${{ inputs.output }}" "${{ inputs.processed_path }}"
# See diff & output diff for comment
- id: diff
shell: bash
run: |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
eof="EOF$RANDOM$(date +%s)"
echo "git_diff<<$eof" >> $GITHUB_OUTPUT
git diff >> $GITHUB_OUTPUT
echo "$eof" >> $GITHUB_OUTPUT
- name: Add preview comment
uses: marocchino/[email protected]
if: ${{ inputs.mode == 'preview' }}
with:
# GITHUB_TOKEN: ${{ inputs.github_token }}
repo: ${{ inputs.repo }}
hide_and_recreate: true
hide_classify: "OUTDATED"
message: |
Changes when this Pull Request is merged:
```diff
${{ steps.diff.outputs.git_diff }}
```
- name: Commit & Push changes
uses: Andro999b/[email protected]
if: ${{ inputs.mode == 'commit' }}
with:
github_token: ${{ inputs.github_token }}
branch: ${{ github.ref }}