forked from NHSDigital/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
784 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: "Build Docs" | ||
description: "build jekyll docs" | ||
inputs: | ||
version: | ||
description: "Version number" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- name: Npm cli install | ||
working-directory: ./docs | ||
run: npm ci | ||
shell: bash | ||
- name: Setup Ruby | ||
uses: ruby/[email protected] | ||
with: | ||
ruby-version: "3.1" # Not needed with a .ruby-version file | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
cache-version: 0 # Increment this number if you need to re-download cached gems | ||
working-directory: "./docs" | ||
- name: Setup Pages | ||
id: pages | ||
uses: actions/configure-pages@v5 | ||
- name: Build with Jekyll | ||
working-directory: ./docs | ||
# Outputs to the './_site' directory by default | ||
shell: bash | ||
run: make build BASE_URL="${{ steps.pages.outputs.base_path }}" VERSION="${{ inputs.version }}" | ||
#run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | ||
env: | ||
JEKYLL_ENV: production | ||
- name: Upload artifact | ||
# Automatically uploads an artifact from the './_site' directory by default | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: "docs/_site/" | ||
name: jekyll-docs-${{ inputs.version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
name: "CI/CD deploy" | ||
name: "2. Deploy docs to GitHub Pages" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "This is the tag that is oging to be deployed" | ||
required: true | ||
default: "latest" | ||
include_prereleases: | ||
type: choice | ||
description: "Include pre-releases" | ||
default: "true" | ||
options: | ||
- "true" | ||
- "false" | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
metadata: | ||
|
@@ -21,7 +29,7 @@ jobs: | |
python_version: ${{ steps.variables.outputs.python_version }} | ||
terraform_version: ${{ steps.variables.outputs.terraform_version }} | ||
version: ${{ steps.variables.outputs.version }} | ||
tag: ${{ steps.variables.outputs.tag }} | ||
# tag: ${{ steps.variables.outputs.tag }} | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
|
@@ -37,7 +45,7 @@ jobs: | |
echo "terraform_version=$(grep "^terraform" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT | ||
# TODO: Get the version, but it may not be the .version file as this should come from the CI/CD Pull Request Workflow | ||
echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT | ||
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | ||
# echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | ||
- name: "List variables" | ||
run: | | ||
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}" | ||
|
@@ -47,31 +55,52 @@ jobs: | |
export PYTHON_VERSION="${{ steps.variables.outputs.python_version }}" | ||
export TERRAFORM_VERSION="${{ steps.variables.outputs.terraform_version }}" | ||
export VERSION="${{ steps.variables.outputs.version }}" | ||
export TAG="${{ steps.variables.outputs.tag }}" | ||
# export TAG="${{ steps.variables.outputs.tag }}" | ||
make list-variables | ||
deploy: | ||
name: "Deploy to an environment" | ||
deploy-jekyll: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: [metadata] | ||
timeout-minutes: 10 | ||
needs: metadata | ||
steps: | ||
- name: "Checkout code" | ||
uses: actions/checkout@v4 | ||
# TODO: More jobs or/and steps here | ||
# success: | ||
# name: "Success notification" | ||
# runs-on: ubuntu-latest | ||
# needs: [deploy] | ||
# steps: | ||
# - name: "Check prerequisites for notification" | ||
# id: check | ||
# run: echo "secret_exist=${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT | ||
# - name: "Notify on deployment to an environment" | ||
# if: steps.check.outputs.secret_exist == 'true' | ||
# uses: nhs-england-tools/[email protected] | ||
# with: | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# teams-webhook-url: ${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL }} | ||
# message-title: "Notification title" | ||
# message-text: "This is a notification body" | ||
# link: ${{ github.event.pull_request.html_url }} | ||
|
||
- name: "Get version" | ||
id: get-asset-version | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
if [[ ${{inputs.include_prereleases}} == true ]]; then | ||
json=$(gh release list --json tagName --limit 1 --exclude-drafts) | ||
else | ||
json=$(gh release list --json tagName --limit 1 --exclude-drafts --exclude-pre-releases) | ||
fi | ||
echo $json | ||
release_version=$(echo $json | (jq -r '.[0].tagName')) | ||
if [[ $release_version == null ]]; then exit 1; else echo $release_version; fi | ||
echo release_version=$(echo $release_version) >> $GITHUB_OUTPUT | ||
- name: "Get release version" | ||
id: download-asset | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh release download ${{steps.get-asset-version.outputs.release_version}} -p jekyll-docs-*.tar --output artifact.tar | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: jekyll-docs-${{steps.get-asset-version.outputs.release_version}} | ||
path: artifact.tar | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
with: | ||
artifact_name: jekyll-docs-${{steps.get-asset-version.outputs.release_version}} |
Oops, something went wrong.