Repository navigation
51 lines (48 loc) · 1.76 KB
/
Copy pathbootstrap-template.yaml
File metadata and controls
51 lines (48 loc) · 1.76 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
name: Bootstrap Template
on:
create:
workflow_dispatch:
push:
permissions:
contents: write
jobs:
bootstrap:
if: github.event.repository.is_template == false && github.actor != 'github-actions[bot]' && (github.event_name != 'create' || github.event.ref_type == 'branch')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}
- name: Detect template placeholders
id: placeholders
run: |
if [ -d project_name ] || grep -R -n "project_name\|python-template" . >/dev/null 2>&1; then
echo "needs_bootstrap=true" >> "$GITHUB_OUTPUT"
else
echo "needs_bootstrap=false" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python
if: steps.placeholders.outputs.needs_bootstrap == 'true'
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Bootstrap repository metadata
if: steps.placeholders.outputs.needs_bootstrap == 'true'
run: python scripts/bootstrap_template.py --from-github
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_ACTOR_ID: ${{ github.actor_id }}
- name: Commit bootstrap changes
if: steps.placeholders.outputs.needs_bootstrap == 'true'
run: |
if git diff --quiet; then
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore(template): bootstrap repository metadata"
git push origin HEAD:${{ github.event.repository.default_branch }}