-
-
Notifications
You must be signed in to change notification settings - Fork 14
61 lines (59 loc) · 1.96 KB
/
push.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
name: Update demo
on:
push:
branches:
- main
jobs:
update_demo:
runs-on: ubuntu-latest
steps:
- name: Checkout python-lib
uses: actions/checkout@v4
with:
path: main
- name: Checkout python-lib-template-demo
uses: actions/checkout@v4
with:
repository: simonw/python-lib-template-demo
path: python-lib-template-demo-current
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_PUSH }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
pip install -r main/requirements.txt
- name: Build demo from template
run: |-
cat main/input-for-demo.txt | cookiecutter main
find python-lib-template-demo
- name: Push to git
env:
PERSONAL_ACCESS_TOKEN_FOR_PUSH: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_PUSH }}
run: |-
# Move the .git folder across
mv python-lib-template-demo-current/.git python-lib-template-demo
# Commit and push the changes
cd python-lib-template-demo
echo "git diff:"
git diff
echo "---"
git config user.name "Automated"
git config user.email "[email protected]"
git add -A .
git commit -m "Demo of python-lib ${GITHUB_SHA}" || exit 0
git push -u origin main
- name: Post commit comment
run: |-
cd python-lib-template-demo
export FULL_SHA=$(git rev-parse HEAD)
export SHORT_SHA=${FULL_SHA::8}
export NEWLINE=$'\n'
echo '{}' | jq --arg v "Demo: https://github.com/simonw/python-lib-template-demo/tree/$SHORT_SHA" \
'. + { body: $v }' | \
curl -sL -X POST -d @- \
-H "Content-Type: application/json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments"