-
-
Notifications
You must be signed in to change notification settings - Fork 5
60 lines (58 loc) · 2.05 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
name: Update demo
on:
push:
branches:
- main
jobs:
update_demo:
runs-on: ubuntu-latest
steps:
- name: Checkout datasette-plugin
uses: actions/checkout@v3
with:
path: main
- name: Checkout datasette-plugin-template-demo
uses: actions/checkout@v3
with:
repository: simonw/datasette-plugin-template-demo
path: datasette-plugin-template-demo-current
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_PUSH }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
pip install -r main/requirements.txt
- name: Run tests
run: pytest main/tests
- name: Build demo from template
run: |-
cat main/input-for-demo.txt | cookiecutter main
find datasette-plugin-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 datasette-plugin-template-demo-current/.git datasette-plugin-template-demo
# Commit and push the changes
cd datasette-plugin-template-demo
git config user.name "Automated"
git config user.email "[email protected]"
git add -A .
git commit -m "Demo of https://github.com/simonw/datasette-plugin/commit/${GITHUB_SHA}" || exit 0
git push -u origin main
- name: Post commit comment
run: |-
cd datasette-plugin-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/datasette-plugin-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"