Explicit build-system, closes #7 #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |