-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (69 loc) · 2.45 KB
/
publish-example.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
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
name: Publish example to python-example
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
publish-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Install dependencies
run: pip install cookiecutter tox
- name: Create working directory
run: mkdir -p .tmp
- name: Check out the python-example repo
uses: actions/checkout@v4
with:
repository: vikahl/python-example
ref: main
path: .tmp/python-example-repo
- name: Empty the python-example repo
run: |
rm -rf .tmp/python-example-repo/*
tree .tmp/
- name: Build example from cookiecutter
working-directory: .tmp
run: |
cookiecutter --config-file $GITHUB_WORKSPACE/config/python-example.yaml \
--no-input $GITHUB_WORKSPACE
- name: Move all files from cookiecutter to the python-example repo
working-directory: .tmp
run: mv python_example/* python-example-repo/
- name: Generate requirements
working-directory: .tmp/python-example-repo
run: |
tox run -m requirements
- name: Configure the python-example git repo
working-directory: .tmp/python-example-repo
run: |
git config user.name "Github actions on vikahl/python-template"
git config user.email "<>"
git remote add python-example \
"https://vikahl:${{ secrets.PYTHON_EXAMPLE_TOKEN
}}@github.com/vikahl/python-example.git"
- name: Unset header that seems to cause auth issues
working-directory: .tmp/python-example-repo
run: git config --unset-all http.https://github.com/.extraheader
- name: Create a new commit
working-directory: .tmp/python-example-repo
run: |
git add .
# Only commit if there are changes
git diff-index --quiet HEAD || git commit -m "Sync from vikahl/python-template $GITHUB_SHA"
- name: Commit (only on main builds)
if: github.ref == 'refs/heads/main'
working-directory: .tmp/python-example-repo
run: git push python-example main