-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
127 lines (126 loc) · 5.27 KB
/
action.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: 'shim Auto Review bot'
description: 'shim Auto Review bot'
inputs:
comment-file:
description: 'comment body file'
required: false
config-file:
description: 'config file'
required: false
default: "/tmp/config.yaml"
issue-repository:
description: 'issue repository'
required: false
default: "${{ github.repository }}"
issue-number:
description: 'issue number'
required: false
source:
description: "source git repository"
required: true
build-script:
description: 'build script'
required: false
output-file:
description: 'generated by build-script output file path'
required: false
vendor-cert:
description: 'vendor cert file'
required: false
sbat:
description: 'sbat file'
required: false
report-output:
description: 'review file output path'
required: false
runs:
using: "composite"
steps:
- name: "Download shim-review-bot"
if: github.action_ref != 'master'
shell: bash
env:
GITHUB_ACTION_REF_EXP: ${{ github.action_ref }}
GITHUB_ACTION_REPOSITORY_EXP: ${{ github.action_repository }}
run: |
mkdir -p "$HOME/.bin/"
echo "$HOME/.bin/" >> $GITHUB_PATH
wget -O "$HOME/.bin/shim-review-bot" https://github.com/$GITHUB_ACTION_REPOSITORY_EXP/releases/download/$GITHUB_ACTION_REF_EXP/shim-review-bot
chmod +x "$HOME/.bin/shim-review-bot"
- uses: actions/setup-go@v4
if: github.action_ref == 'master'
with:
go-version: '>=1.20.0'
- name: "Build shim-review-bot"
if: github.action_ref == 'master'
shell: bash
env:
GITHUB_ACTION_REF_EXP: ${{ github.action_ref }}
GITHUB_ACTION_REPOSITORY_EXP: ${{ github.action_repository }}
run: |
mkdir -p "$HOME/.bin/"
echo "$HOME/.bin/" >> $GITHUB_PATH
cd ${{ github.action_path }}
/bin/bash ./bot-build.sh
cp shim-review-bot $HOME/.bin/shim-review-bot
- name: Create Comment
id: comment
if: inputs.issue-number != ''
uses: peter-evans/[email protected]
with:
issue-number: "${{ inputs.issue-number }}"
body: |
**Disclaimer: I am not a not an authorized reviewer. Automatic reproduction check bot (https://github.com/jc-lab/shim-review-bot).**
Job URL : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: parse-comment
if: inputs.comment-file != ''
shell: bash
run: |
shim-review-bot parse-comment --config "${{ inputs.config-file }}" --comment-file "${{ inputs.comment-file }}"
cat "${{ inputs.config-file }}"
- name: setup-buildx
uses: docker/setup-buildx-action@v3
- id: clone
shell: bash
run: |
if [ -f "${{ inputs.config-file }}" ]; then
shim-review-bot download --config "${{ inputs.config-file }}" --source "${{ inputs.source }}" --dest "/tmp/source" > /tmp/working-directory.txt
else
shim-review-bot download --source "${{ inputs.source }}" --dest "/tmp/source" > /tmp/working-directory.txt
fi
- id: review
shell: bash
run: |
[ -n "${{ inputs.output-file }}" ] && export BUILD_OUTPUT_FILE="${{ inputs.output-file }}" || export BUILD_OUTPUT_FILE="output.tar"
[ -n "${{ inputs.build-script }}" ] && BUILD_SCRIPT="${{ inputs.build-script }}" || BUILD_SCRIPT="${{ github.action_path }}/default-build-script.sh"
[ -n "${{ inputs.vendor-cert }}" ] && export VENDOR_CERT="${{ inputs.vendor-cert }}" || export VENDOR_CERT="vendor_cert.der"
[ -n "${{ inputs.sbat }}" ] && export SBAT_FILE="${{ inputs.sbat }}" || export SBAT_FILE="sbat.csv"
[ -n "${{ inputs.report-output }}" ] && export REPORT_OUTPUT="${{ inputs.report-output }}" || export REPORT_OUTPUT="/tmp/report.md"
echo "REPORT_OUTPUT=${REPORT_OUTPUT}" >> "$GITHUB_ENV"
cd $(cat /tmp/working-directory.txt)
echo "WORKING DIRECTORY: $PWD"
ls -al
echo ""
if [ -f "${{ inputs.config-file }}" ]; then
shim-review-bot review --config "${{ inputs.config-file }}" --source-root "/tmp/source" --build-script "${BUILD_SCRIPT}" --output-file "${BUILD_OUTPUT_FILE}" --sbat "${SBAT_FILE}" --vendor-cert "${VENDOR_CERT}" --report-output "/tmp/report-generated.md"
else
shim-review-bot review --source-root "/tmp/source" --build-script "${BUILD_SCRIPT}" --output-file "${BUILD_OUTPUT_FILE}" --sbat "${SBAT_FILE}" --vendor-cert "${VENDOR_CERT}" --report-output "/tmp/report-generated.md"
fi
touch ${REPORT_OUTPUT}
[ -n "${{ inputs.build-script }}" ] && echo "Used Build Script: ${{ inputs.build-script }}" >> ${REPORT_OUTPUT} || echo "Used Dockerfile: Dockerfile" >> ${REPORT_OUTPUT}
cat /tmp/report-generated.md >> ${REPORT_OUTPUT}
- id: report
if: inputs.issue-number != ''
uses: peter-evans/[email protected]
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
edit-mode: append
body-path: "${{ env.REPORT_OUTPUT }}"
- name: Failed report
if: failure()
uses: peter-evans/[email protected]
with:
comment-id: "${{ steps.comment.outputs.comment-id }}"
edit-mode: append
body: |
Action failed