diff --git a/copier.yaml b/copier.yaml index f666f02..8e2ed0d 100644 --- a/copier.yaml +++ b/copier.yaml @@ -55,6 +55,13 @@ github_user: help: "What is the name of the GitHub user or organisation where the repository will be or is stored?" default: "{{ 'seedcase-project' if is_seedcase_project else '' }}" +hosting_provider: + type: str + help: "What hosting provider will you use for the documentation website?" + choices: + - netlify + - gh-pages + homepage: type: str help: "What is the homepage of your project?" diff --git a/justfile b/justfile index 67a05cb..807d2f3 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,7 @@ @_checks: check-spelling check-commits # Test Seedcase and non-Seedcase projects -@_tests: (test "true") (test "false") +@_tests: (test "true" "netlify") (test "false" "netlify") (test "true" "gh-pages") (test "false" "gh-pages") @_builds: build-contributors build-website build-readme # Run all build-related recipes in the justfile @@ -47,10 +47,10 @@ check-commits: check-spelling: uvx typos -# Test and check that a Python package can be created from the template -test is_seedcase_project: +# 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") +test is_seedcase_project="true" hosting_provider="netlify": #!/usr/bin/env bash - test_name="test-python-package" + test_name="test-package-{{ hosting_provider }}" test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name" template_dir="$(pwd)" commit=$(git rev-parse HEAD) @@ -61,6 +61,7 @@ test is_seedcase_project: --defaults \ --trust \ --data is_seedcase_project={{ is_seedcase_project }} \ + --data hosting_provider={{ hosting_provider }} \ --data github_user="first-last" \ --data author_given_name="First" \ --data author_family_name="Last" \ @@ -95,6 +96,7 @@ test is_seedcase_project: --trust \ --overwrite \ --data is_seedcase_project={{ is_seedcase_project }} \ + --data hosting_provider={{ hosting_provider }} \ --data github_user="first-last" \ --data author_given_name="First" \ --data author_family_name="Last" \ diff --git a/template/.github/workflows/build-website.yml b/template/.github/workflows/build-website.yml deleted file mode 100644 index b24f3c4..0000000 --- a/template/.github/workflows/build-website.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Build website - -on: - push: - branches: - - main - -# Limit token permissions for security -permissions: read-all - -jobs: - build-website: - uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main - secrets: - netlify-token: ${{ secrets.NETLIFY_AUTH_TOKEN }} - # This is to allow using `gh` CLI - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/template/.github/workflows/build-website.yml.jinja b/template/.github/workflows/build-website.yml.jinja new file mode 100644 index 0000000..4b5543e --- /dev/null +++ b/template/.github/workflows/build-website.yml.jinja @@ -0,0 +1,26 @@ +name: Build website + +on: + push: + branches: + - main + +# Limit token permissions for security +permissions: read-all + +jobs: + build-website: + uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main + {%- if hosting_provider == 'gh-pages' %} + with: + hosting-provider: gh-pages + permissions: + contents: write + pages: write + {%- endif %} + secrets: + {% if hosting_provider == 'gh-pages' -%} + github-token: {{ '${{ secrets.GITHUB_TOKEN }}' }} + {%- elif hosting_provider == 'netlify' -%} + netlify-token: {{ '${{ secrets.NETLIFY_AUTH_TOKEN }}' }} + {%- endif %} diff --git a/template/_publish.yml b/template/_publish.yml deleted file mode 100644 index 972233d..0000000 --- a/template/_publish.yml +++ /dev/null @@ -1,5 +0,0 @@ -- source: project - netlify: - # TODO: Include Netlify details - - id: "" - url: "" diff --git a/template/_quarto.yml.jinja b/template/_quarto.yml.jinja index ce8fc8a..91a2562 100644 --- a/template/_quarto.yml.jinja +++ b/template/_quarto.yml.jinja @@ -11,7 +11,12 @@ project: website: # TODO: Fill in the title of the website. title: "" + {% if hosting_provider == "gh-pages" -%} + site-url: "https://{{ github_user }}.github.io/{{ github_repo }}/" + {%- elif hosting_provider == "netlify" -%} + # TODO: Set the Netlify custom domain URL site-url: "{{ homepage }}" + {%- endif %} repo-url: "https://github.com/{{ github_repo_spec }}" page-navigation: true navbar: diff --git "a/template/{% if hosting_provider == \"netlify\" %}_publish.yml{% endif %}.jinja" "b/template/{% if hosting_provider == \"netlify\" %}_publish.yml{% endif %}.jinja" new file mode 100644 index 0000000..1b8bb0b --- /dev/null +++ "b/template/{% if hosting_provider == \"netlify\" %}_publish.yml{% endif %}.jinja" @@ -0,0 +1,5 @@ +- source: project + netlify: + # TODO: Include correct ID and URL + - id: "" + url: "https://{{ github_user }}-{{ github_repo }}.netlify.app"