Skip to content

Commit 498fbc4

Browse files
feat: ✨ add hosting provider variable (#153)
# Description This PR adds the `hosting_provider` copier variable. Moved from #140 . Closes #119 This PR needs a medium-depth review. ## Checklist - [x] Added or updated tests - [x] Updated documentation - [x] Ran `just run-all` Co-authored-by: Luke W. Johnston <lwjohnst86@users.noreply.github.com>
1 parent 146ee10 commit 498fbc4

File tree

7 files changed

+49
-26
lines changed

7 files changed

+49
-26
lines changed

copier.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ github_user:
6565
help: "What is the name of the GitHub user or organisation where the repository will be or is stored?"
6666
default: "{{ 'seedcase-project' if is_seedcase_project else '' }}"
6767

68+
hosting_provider:
69+
type: str
70+
help: "What hosting provider will you use for the documentation website?"
71+
choices:
72+
- netlify
73+
- gh-pages
74+
6875
homepage:
6976
type: str
7077
help: "What is the homepage of your project?"

justfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@_checks: check-spelling check-commits
55
# Test Seedcase and non-Seedcase projects
6-
@_tests: (test "true") (test "false")
6+
@_tests: (test "true" "netlify") (test "false" "netlify") (test "true" "gh-pages") (test "false" "gh-pages")
77
@_builds: build-contributors build-website build-readme
88

99
# Run all build-related recipes in the justfile
@@ -47,10 +47,10 @@ check-commits:
4747
check-spelling:
4848
uvx typos
4949

50-
# Test and check that a Python package can be created from the template
51-
test is_seedcase_project:
50+
# Test that a Python package can be created from the template, with parameters for: `is_seedcase_project` (true or false) and `hosting_provider` (either "gh-pages" or "netlify")
51+
test is_seedcase_project="true" hosting_provider="netlify":
5252
#!/usr/bin/env bash
53-
test_name="test-python-package"
53+
test_name="test-package-{{ hosting_provider }}"
5454
test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name"
5555
template_dir="$(pwd)"
5656
commit=$(git rev-parse HEAD)
@@ -61,6 +61,7 @@ test is_seedcase_project:
6161
--defaults \
6262
--trust \
6363
--data is_seedcase_project={{ is_seedcase_project }} \
64+
--data hosting_provider={{ hosting_provider }} \
6465
--data github_user="first-last" \
6566
--data author_given_name="First" \
6667
--data author_family_name="Last" \
@@ -95,6 +96,7 @@ test is_seedcase_project:
9596
--trust \
9697
--overwrite \
9798
--data is_seedcase_project={{ is_seedcase_project }} \
99+
--data hosting_provider={{ hosting_provider }} \
98100
--data github_user="first-last" \
99101
--data author_given_name="First" \
100102
--data author_family_name="Last" \

template/.github/workflows/build-website.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build website
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Limit token permissions for security
9+
permissions: read-all
10+
11+
jobs:
12+
build-website:
13+
uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main
14+
{%- if hosting_provider == 'gh-pages' %}
15+
with:
16+
hosting-provider: gh-pages
17+
permissions:
18+
contents: write
19+
pages: write
20+
{%- endif %}
21+
secrets:
22+
{% if hosting_provider == 'gh-pages' -%}
23+
github-token: {{ '${{ secrets.GITHUB_TOKEN }}' }}
24+
{%- elif hosting_provider == 'netlify' -%}
25+
netlify-token: {{ '${{ secrets.NETLIFY_AUTH_TOKEN }}' }}
26+
{%- endif %}

template/_publish.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

template/_quarto.yml.jinja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ project:
1111
website:
1212
# TODO: Fill in the title of the website.
1313
title: ""
14+
{% if hosting_provider == "gh-pages" -%}
15+
site-url: "https://{{ github_user }}.github.io/{{ github_repo }}/"
16+
{%- elif hosting_provider == "netlify" -%}
17+
# TODO: Set the Netlify custom domain URL
1418
site-url: "{{ homepage }}"
19+
{%- endif %}
1520
repo-url: "https://github.com/{{ github_repo_spec }}"
1621
page-navigation: true
1722
navbar:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- source: project
2+
netlify:
3+
# TODO: Include correct ID and URL
4+
- id: ""
5+
url: "https://{{ github_user }}-{{ github_repo }}.netlify.app"

0 commit comments

Comments
 (0)