Skip to content

Commit

Permalink
various workflow improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Dec 1, 2023
1 parent 64eceda commit 52230d0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
10 changes: 5 additions & 5 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ def remove_file(filepath):
Path(PROJECT_DIRECTORY).joinpath(filepath).unlink()


def remove_folder(folderpath):
for file in Path(PROJECT_DIRECTORY).joinpath(folderpath).iterdir():
def remove_folder(folder_path):
for file in Path(PROJECT_DIRECTORY).joinpath(folder_path).iterdir():
if not file.is_dir():
file.unlink()
continue
file.rmdir()
Path(PROJECT_DIRECTORY).joinpath(folderpath).rmdir()
Path(PROJECT_DIRECTORY).joinpath(folder_path).rmdir()


def replace_contents(filepath):
replacements = {
"__GITHUB_REF__": "github.ref",
"__BUMPVERSION_TOKEN__": "secrets.BUMPVERSION_TOKEN",
"__GITHUB_REF_NAME__": "github.ref_name",
"__GITHUB_TOKEN__": "secrets.GITHUB_TOKEN",
"__PYTHON_VERSION__": "matrix.python-version",
"__TOX_ENV__": "matrix.tox-env",
"__WORKFLOW_TOKEN__": "secrets.WORKFLOW_TOKEN",
}

lines = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This workflow requires a personal access token repository secret named `BUMPVERSION_TOKEN` with the following privileges:
# - repo
# - workflow

name: GitHub Actions Version Updater

on:
Expand All @@ -13,12 +17,12 @@ jobs:
- uses: actions/[email protected]
with:
# This requires a personal access token with the privileges to push directly to `main`
token: __WORKFLOW_TOKEN__
token: __BUMPVERSION_TOKEN__
persist-credentials: true
- name: Run GitHub Actions Version Updater
uses: saadmk11/[email protected]
with:
token: __WORKFLOW_TOKEN__
token: __BUMPVERSION_TOKEN__
committer_email: 'bumpversion[bot]@ouranos.ca'
committer_username: 'update-github-actions[bot]'
pull_request_title: '[bot] Update GitHub Action Versions'
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This workflow requires a personal access token named `BUMPVERSION_TOKEN` with the following privileges:
# - repo
# - workflow

name: "Bump Patch Version"

on:
Expand All @@ -17,8 +21,8 @@ on:
{%- if cookiecutter.create_author_file == 'y' %}
- AUTHORS.rst
{%- endif %}
- CONTRIBUTING.rst
- CHANGES.rst
- CONTRIBUTING.rst
- Makefile
{%- if cookiecutter.make_docs == 'y' %}
- .readthedocs.yml
Expand All @@ -29,7 +33,6 @@ on:
{%- if cookiecutter.use_conda == 'y' %}
- environment-dev.yml
{%- endif %}
- setup.cfg
- pyproject.toml
- tests/**.py
- tox.ini
Expand Down Expand Up @@ -62,5 +65,5 @@ jobs:
uses: ad-m/github-push-action@master
with:
force: false
github_token: __WORKFLOW_TOKEN__
github_token: __BUMPVERSION_TOKEN__
branch: __GITHUB_REF__
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
repo: context.repo.repo,
body: `**Welcome**, new contributor!
It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the \`AUTHORS.rst\` and \`.zenodo.json\`.:
It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the \`AUTHORS.rst\` and \`.zenodo.json\`:
- [ ] The relevant author information has been added to \`AUTHORS.rst\` and \`.zenodo.json\`.
Please make sure you've read our [contributing guide](CONTRIBUTING.rst). We look forward to reviewing your Pull Request shortly ✨`
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ on:
branches:
- main
paths-ignore:
- .cruft.json
- CHANGES.rst
- README.rst
- pyproject.toml
- setup.cfg
- tests/test_{{ cookiecutter.project_slug }}.py
- {{ cookiecutter.project_slug }}/__init__.py
pull_request:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: __GITHUB_TOKEN__
with:
tag_name: __GITHUB_REF__
name: Release __GITHUB_REF__
tag_name: __GITHUB_REF_NAME__
name: Release __GITHUB_REF_NAME__
draft: true
prerelease: false

Expand Down

0 comments on commit 52230d0

Please sign in to comment.