Skip to content

Commit

Permalink
ci: update docs release workflow (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylesomers authored Jun 4, 2024
1 parent 3eb081e commit 43f6c53
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#====================================================================================================
## Process
# 1. When changes are made to documentation files and pushed to the main branch, the workflow in this file is triggered.
# 2. Copy the repository's contents to the runner, so the workflow can access them.
# 3. Run a script that sets the version number.
# 4. `make docs-build` is run within a Docker container to build the documentation .
# 5. `make docs-deploy` is run inside Docker container to deploy the documentation to GitHub Pages.
#====================================================================================================
name: Build Docs and Publish to gh-pages
on:
push:
Expand All @@ -10,24 +18,45 @@ on:
- "**/README.md"
- ".github/workflows/docs.yml"
workflow_dispatch:
inputs:
version:
description: "Version to build and publish docs (i.e. 0.1.0-alpha.1, latest)"
required: true
type: string
alias:
description: "Alias to associate version (latest, stage)"
required: true
type: string
git_ref:
description: "Branch or commit ID to checkout from"
required: false
type: string
default: main
permissions:
contents: write
jobs:
publish_docs:
if: github.repository == 'aws-games/cloud-game-development-toolkit'
concurrency:
group: docs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
fetch-depth: 0
ref: ${{ inputs.git_ref }}
- name: Git client setup
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Set version
run: |
echo "Tag name from github.ref_name: ${{ github.ref_name }}"
echo "VERSION is: ${{ inputs.version }}"
echo "ALIAS is: ${{ inputs.alias }}"
- name: Build docs
run: make docs-build
run: make docs-build VERSION=$RELEASE_VERSION
- name: Deploy Docs
run: make docs-deploy
run: make docs-deploy VERSION="$RELEASE_VERSION" ALIAS="$ALIAS"

8 changes: 4 additions & 4 deletions .github/workflows/ossf_scorecard.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Scorecard supply-chain security
on:
branch_protection_rule:
schedule:
- cron: '0 0 * * *'
push:
branches: [ "main" ]
#schedule:
# - cron: '0 0 * * *'
#push:
# branches: [ "main" ]
workflow_dispatch:
permissions: read-all
jobs:
Expand Down
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

###########################################################
# ENVIRONMENT VARIABLES
# Define the environment variables
###########################################################
ifeq ($(GITHUB_ACTIONS),true)
GIT_USER_NAME := github-actions[bot]
Expand All @@ -31,36 +30,33 @@ endif

###########################################################
# docs-build
# Build the docs using docker
###########################################################
docs-build: ## Build the docs using docker
docs-build: ## Build the docs using docker. Example: `make docs-build VERSION=1.0.0`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . --build-arg GIT_USER_NAME="$(GIT_USER_NAME)" --build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" --build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) --no-cache

###########################################################
# docs-deploy
# Deploy the docs using 'mike'
###########################################################
docs-deploy: ## Deploy the docs using 'mike'
docs-deploy: ## Deploy the docs using 'mike'. Example: `make docs-deploy VERSION=1.0.0 ALIAS=latest`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@if [ -z "${ALIAS}" ]; then echo -e "${RED}ALIAS is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker run -t docs:$(VERSION) mike deploy --push --update-aliases $(VERSION) latest
docker run -t docs:$(VERSION) mike deploy --push --update-aliases $(VERSION) ${ALIAS}

###########################################################
# docs-local-docker
# Build and run the docs locally using docker and 'serve'
###########################################################
docs-local-docker: ## Build and run the docs locally using docker and 'serve'
docs-local-docker: ## Build and run the docs locally using docker and 'serve'. Example: `make docs-local-docker VERSION=1.0.0`
@if [ -z "${VERSION}" ]; then echo -e "${RED}VERSION is not set. Run 'make help' for usage. ${RESET}"; exit 1; fi
@echo -e "Docs version is: ${GREEN}$(VERSION)${RESET}"
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . --build-arg GIT_USER_NAME="$(GIT_USER_NAME)" --build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" --build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) --no-cache
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs docs:$(VERSION) mkdocs serve --dev-addr=0.0.0.0:8000
docker build -f ./docs/Dockerfile -t docs:$(VERSION) . --build-arg GIT_USER_NAME="$(GIT_USER_NAME)" --build-arg GIT_USER_EMAIL="$(GIT_USER_EMAIL)" --build-arg GITHUB_ACTIONS=$(GITHUB_ACTIONS) --no-cache
docker run -t docs:$(VERSION) mike deploy --push --update-aliases $(VERSION) latest

###########################################################
# help
# Display this help
###########################################################
help: ## Display this help
@echo -e "Usage: make [TARGET] VERSION=<version>\n"
@echo -e "Usage: make [TARGET]\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${CYAN}%-30s${RESET} %s\n", $$1, $$2}'

0 comments on commit 43f6c53

Please sign in to comment.