forked from mach-composer/plan-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
64 lines (56 loc) · 1.97 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
name: 'Mach Composer Plan'
description: 'Run mach-composer plan and update PR'
inputs:
filename:
description: 'name of the mach-composer config file'
required: true
default: 'main.yml'
github-token:
description: 'Your github token'
required: true
working-directory:
description: 'The working directory to run mach-composer in'
required: false
default: '.'
plan-args:
description: 'Additional arguments to pass to mach-composer plan'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Run MACH Composer plan
shell: bash
working-directory: ${{ inputs.working-directory }}
run: mach-composer plan -f ${{ inputs.filename }} ${{ inputs.plan-args }}
id: plan
- name: Show MACH Composer plan
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
mach-composer show-plan -f ${{ inputs.filename }} --no-color | grep -v "^::debug::" >${GITHUB_WORKSPACE}/plan.out
id: show-plan
- name: Update Pull Request
uses: actions/github-script@v6
if: github.event.pull_request.merged != true
with:
github-token: ${{ inputs.github-token }}
script: |
const fs = require('fs');
const plan = fs.readFileSync('plan.out', 'utf8');
const planOutput = plan.length > 65000 ? plan.substring(0, 65000) : plan;
const truncatedMessage = plan.length > 65000 ? "Output is too long and has been truncated" : "";
const output = `#### MACH composer plan 📖
<details><summary>Show Plan</summary>
\`\`\`hcl\n
${planOutput}
\`\`\`
</details>
${truncatedMessage}
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})