Skip to content

Commit

Permalink
Add Github actions workflow publishing to python-example
Browse files Browse the repository at this point in the history
Add a Github actions workflow that publishes a generated cookiecutter on
the repo vikahl/python-example
  • Loading branch information
vikahl committed Oct 18, 2023
1 parent 23f32c7 commit de8fae3
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/publish-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish example to python-example

on:
push:
branches: [ main ]
pull_request: # REMOVE THIS BEFORE MERGE
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@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: |
3.8
3.9
3.10
3.11
3.12
- name: Install dependencies
run: pip install cookiecutter tox

- run: mkdir -p /tmp/generated

- run: pwd

- name: Build example repo
working-directory: /tmp/generated
run: |
cookiecutter --config-file ../config/python-example.yaml \
--no-input ../
- name: Generate requirements
working-directory: /tmp/generated/python_example
run: tox run -m requirements

- name: Initialise the git repo
working-directory: /tmp/generated/python_example
run: |
git init
git config user.name "Github actions on vikahl/python-template"
git config user.email "<>"
git remote add python-example "https://vikahl:[email protected]/vikahl/python-example.git"
- name: Unset header that seems to cause auth issues
working-directory: /tmp/generated/python_example
run: git config --unset-all http.https://github.com/.extraheader

- name: Check out a new branch, commit and push
working-directory: /tmp/generated/python_example
run: |
git checkout -b "sync-$COMMIT"
git add .
git commit -m "Sync from vikahl/python-template $COMMIT"
git push python-example main --force
14 changes: 14 additions & 0 deletions config/python-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default_context:
h: ""
project_name: "Python project example"
description: "Example project generated from vikahl/python-template"
module_name: "python_project_example"
author: "Viktor Rimark"
email: "[email protected]"
homepage: "https://blog.rxbx.se"
license: "GPL - ensures that code based on this is shared with the same terms"
version: "1.0.0"
min_python: "3.8"
library: "y"
cli: "y"
service: "y"

0 comments on commit de8fae3

Please sign in to comment.