-
Notifications
You must be signed in to change notification settings - Fork 3
98 lines (90 loc) · 3.31 KB
/
sync-devchat.yml
File metadata and controls
98 lines (90 loc) · 3.31 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
96
97
98
name: Sync up devchat packages
on:
workflow_dispatch:
inputs:
devchat_branch:
description: "The branch of devchat to sync up with"
required: true
default: "main"
type: string
# push:
# branches:
# - ci
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: main
- name: Clone devchat repo to a temporary directory
uses: actions/checkout@v4
with:
repository: devchat-ai/devchat
path: ./temp/devchat-repo
ref: ${{ github.event.inputs.devchat_branch }}
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "1.5.8-0"
init-shell: bash
environment-name: devchat_no_binary
create-args: >-
python=3.8
- name: Generate the latest site-packages for devchat
shell: micromamba-shell {0}
run: |
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
ITEMS_BEFORE=$(mktemp)
ls $SITE_PACKAGES > "$ITEMS_BEFORE"
echo ">>>>>>>>>> Start installing devchat dependencies..."
cd ./temp/devchat-repo
DEVCHAT_HEXSHA=$(git rev-parse HEAD | cut -c 1-8)
DEVCHAT_BRANCH=$(git branch --show-current)
DEVCHAT_MESSAGE=$(git log -1 --pretty=%s)
pip install --no-binary :all: "pydantic==1.10.14"
pip install charset-normalizer --no-binary :all:
pip install git+https://github.com/devchat-ai/tiktoken.git
pip install .
echo ">>>>>>>>>> Finish installing."
pip list
ITEMS_AFTER=$(mktemp)
ls $SITE_PACKAGES > "$ITEMS_AFTER"
echo ">>>>>>>>>> Replace the site-packages with the new one"
ITEMS_DIFF=$(comm -13 "$ITEMS_BEFORE" "$ITEMS_AFTER")
cd ../..
mv ./site-packages ./temp/site-packages-bk
mkdir -p ./site-packages
for item in $ITEMS_DIFF; do
cp -r "$SITE_PACKAGES/$item" ./site-packages
done
rm -rf ./temp
echo "DEVCHAT_HEXSHA=$DEVCHAT_HEXSHA" >> $GITHUB_ENV
echo "DEVCHAT_BRANCH=$DEVCHAT_BRANCH" >> $GITHUB_ENV
echo "DEVCHAT_MESSAGE=$DEVCHAT_MESSAGE" >> $GITHUB_ENV
- name: Commit, Push and Create PR
run: |
git config --local user.email "mingjing@merico.dev"
git config --local user.name "Sync-Packages Action"
TIMESTAMP=$(date +'%y%m%d-%H%M%S')
BRANCH_NAME=sync-$TIMESTAMP
git checkout -b $BRANCH_NAME
git diff --stat
git add ./site-packages
git commit -m "Sync: devchat[$DEVCHAT_BRANCH]($DEVCHAT_HEXSHA) $DEVCHAT_MESSAGE"
git status
git push origin $BRANCH_NAME
echo -e "This PR is auto-generated by GitHub Action. \n- devchat branch: \`$DEVCHAT_BRANCH\` \n- devchat hexsha: \`$DEVCHAT_HEXSHA\` \n- message: $DEVCHAT_MESSAGE \n- actor: ${{ github.triggering_actor }}" > pr_body
PR_BODY=$(cat pr_body)
gh pr create \
--title ":arrows_counterclockwise: Sync: [$DEVCHAT_BRANCH]($DEVCHAT_HEXSHA) $DEVCHAT_MESSAGE ($TIMESTAMP)" \
--body "$PR_BODY" \
--draft \
--base main \
--head $BRANCH_NAME
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}