-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 3.18 KB
/
build.yml
File metadata and controls
95 lines (81 loc) · 3.18 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
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
name: CodeHeal
on:
pull_request:
types: [opened, synchronize]
env:
PR_NUMBER: pr${{ github.event.pull_request.number }}
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
version: [18]
# outputs:
# buildtimeMetadata: ${{ steps.healBuildtime.outputs.output }}
# runtimeMetadata: ${{ steps.healRuntime.outputs.output }}
steps:
- uses: actions/checkout@v3
- name: Set up Node ${{ matrix.version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.version }}
registry-url: https://registry.npmjs.org
- name: Restore & cache dependencies
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('package-lock.json') }}
${{ runner.os }}-
- name: Install dependencies
run: npm install
- name: Run build
id: build
env:
BUILD_OUTPUT_FILE: build_output_${{ github.run_id }}.txt
run: |
set -o pipefail
npm run build 2>&1 | tee build_output_${{ github.run_id }}.txt
exit ${PIPESTATUS[0]}
# - name: Run CodeHeal action
# if: failure()
# uses: ./
# with:
# build-output-file: build_output_${{ github.run_id }}.txt
# openai-key: ${{ secrets.OPENAI_API_KEY }} # perms: fetch code fix suggestions
# github-key: ${{ secrets.GITHUB_TOKEN }} # perms: open pr with code fixes
- name: Run CodeHeal - Build-time Errors
id: healBuildtime
if: failure()
run: npm run heal:buildtime
# - name: Run CodeHeal - Run-time Errors
# id: healRuntime
# run: npm run heal:runtime
- name: Heal, Branch, Commit, Open PR
if: failure() # uncomment after testing
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_OUTPUT_FILE: build_output_id${{ github.run_id }}.txt
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
BUILD_TIME_METADATA: ${{ steps.healBuildtime.outputs.output }}
RUN_TIME_METADATA: ${{ steps.healRuntime.outputs.output }}
run: |
npm run heal:buildtime
# configure git
git config --global user.name "CodeHealBot"
git config --global user.email "action@github.com"
git config --global pull.rebase true
# branch-out & push
git checkout -B ${{ env.PR_BRANCH_NAME_FIX }}
git add --all
git diff-index --quiet HEAD || git commit -m "Fix (${{ env.PR_NUMBER }}): Resolved error(s) with CodeHealBot"
git push origin ${{ env.PR_BRANCH_NAME_FIX }}
# open PR to original branch
gh pr create --base ${{ env.PR_BRANCH_NAME }} --head ${{ env.PR_BRANCH_NAME_FIX }} --title "Fix: Resolving error found on ${{ env.PR_NUMBER }}" --body "It should build without errors now (I guess)"
# TODO:
# - If PR already created, sync pr branch with origin branch
# - Add PR fix reviewer as origin branch owner