Skip to content

👽 Apply changes from cookiecutter-python-cli-app #34

👽 Apply changes from cookiecutter-python-cli-app

👽 Apply changes from cookiecutter-python-cli-app #34

Workflow file for this run

name: Update Demo
on:
push:
branches:
- main
env:
TEMPLATE: cookiecutter-python-package
CURRENT_DEMO: cookiecutter-python-package-demo-current
DEMO: cookiecutter-python-package-demo
jobs:
update_demo:
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ env.TEMPLATE }}
uses: actions/checkout@v4
with:
path: ${{ env.TEMPLATE }}
- name: Checkout ${{ env.DEMO }}
uses: actions/checkout@v4
with:
repository: "sgraaf/${{ env.DEMO }}"
token: ${{ secrets.X_GITHUB_PAT }}
path: ${{ env.CURRENT_DEMO }}
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Build Demo
run: |
cat "${{ env.TEMPLATE }}/.github/workflows/input-for-demo.txt" | pipx run cookiecutter "${{ env.TEMPLATE }}"
find "${{ env.DEMO }}"
- name: Commit and push changes
run: |
mv "${{ env.CURRENT_DEMO }}/.git" "${{ env.DEMO }}"
cd "${{ env.DEMO }}"
git config user.name "Automated"
git config user.email "[email protected]"
git add -A
git commit -m "Demo of ${{ env.TEMPLATE }} @ ${GITHUB_SHA::7}" || exit 0
git push
- name: Post commit comment
run: |
export FULL_SHA=$(git rev-parse HEAD)
echo '{}' | \
jq --arg v "Demo: https://github.com/sgraaf/${{ env.DEMO }}/tree/${FULL_SHA::7}" '. + { body: $v }' | \
curl -sL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" \
-d @-
working-directory: ${{ env.DEMO }}