-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (46 loc) · 1.7 KB
/
codeflash-optimize.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
name: Codeflash
on:
pull_request:
workflow_dispatch:
jobs:
optimize:
name: Optimize new code in this PR
runs-on: ubuntu-latest
env:
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
steps:
- name: Check if PR is from Codeflash bot
id: bot_check
working-directory: .
run: |
echo "Checking if this PR is created by Codeflash bot..."
if [ "${{ github.event.pull_request.user.login }}" == "codeflash-ai[bot]" ]; then
echo "PR created by Codeflash bot. Skipping optimization."
echo "skip_remaining_steps=yes" >> $GITHUB_OUTPUT
else
echo "skip_remaining_steps=no" >> $GITHUB_OUTPUT
echo "It's not. Proceeding with the optimization."
fi
- uses: actions/checkout@v3
if: steps.bot_check.outputs.skip_remaining_steps == 'no'
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
# TODO: Replace this with your project's python installation method
- name: Set up Python
if: steps.bot_check.outputs.skip_remaining_steps == 'no'
uses: actions/setup-python@v4
with:
python-version: 3.9
# TODO: Replace this with your project's dependency installation method
- name: Install Project Dependencies
if: steps.bot_check.outputs.skip_remaining_steps == 'no'
run: |
python -m pip install --upgrade pip hatch
hatch run pip install codeflash
- name: Run Codeflash to optimize code
if: steps.bot_check.outputs.skip_remaining_steps == 'no'
id: optimize_code
run: |
hatch run codeflash