diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index d02ca0698..000000000 --- a/.dockerignore +++ /dev/null @@ -1,8 +0,0 @@ -# Top level files and directories -/.circleci/ -/.dockerignore -/.gcloudignore -/.git/ -/_output/ -/cloudbuild.yaml -/Dockerfile diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index ff8b005f5..9dd0f9c2b 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -37,11 +37,46 @@ jobs: runs-on: ubuntu-latest needs: build steps: + - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install packages + run: | + git config --global url."https://${{ secrets.MKDOCS_INSIDERS_TOKEN }}@github".insteadOf https://github + pip install git+https://github.com/squidfunk/mkdocs-material-insiders.git mkdocs-redirects mike + + - name: Configure git credentials + run: | + git config --global user.name 'TriggerMesh Bot' + git config --global user.email 'bot@triggermesh.com' + + - name: Configure DOCS_VERSION + id: docs-version + run: | + [[ "${GITHUB_REF_TYPE}" == "tag" ]] && DOCS_VERSION=${GITHUB_REF_NAME:1} + echo "DOCS_VERSION=${DOCS_VERSION:-DEV}" >> $GITHUB_OUTPUT + + - name: Deploy version and push + run: | + DOCS_VERSION="${{ steps.docs-version.outputs.DOCS_VERSION }}" + if [[ "${DOCS_VERSION}" != "DEV" ]]; then + mike deploy ${DOCS_VERSION} latest --update-aliases --push + else + mike deploy ${DOCS_VERSION} + fi + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 + - name: Login to GCR if: github.event_name != 'pull_request' uses: docker/login-action@v2 @@ -49,6 +84,7 @@ jobs: registry: gcr.io username: _json_key password: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }} + - name: Docker metadata id: meta uses: docker/metadata-action@v4 @@ -57,12 +93,14 @@ jobs: tags: | type=semver,pattern={{raw}} type=sha - - name: Build image and push to container registries + + - name: Switch to gh-pages branch + run: git checkout gh-pages + + - name: Build and push image uses: docker/build-push-action@v3 with: context: . - build-args: | - MKDOCS_INSIDERS_TOKEN=${{ secrets.MKDOCS_INSIDERS_TOKEN }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore index 233dac42d..4eb65a252 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ .DS_Store /.idea/ /.vscode/ +.envrc # Build artifacts **/_output +/site/ diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f58d53911..000000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM python:3 AS builder - -ARG MKDOCS_INSIDERS_TOKEN= - -RUN pip install git+https://${MKDOCS_INSIDERS_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git@8.5.8-insiders-4.26.2 mkdocs-redirects - -COPY . /docs - -RUN mkdocs build --clean --config-file /docs/mkdocs.yml - -FROM nginx - -COPY --from=builder /docs/site/ /usr/share/nginx/html/ diff --git a/Makefile b/Makefile index 95cb7e2f0..0d6df82f8 100644 --- a/Makefile +++ b/Makefile @@ -17,13 +17,13 @@ IMAGE_SHA ?= $(shell git rev-parse HEAD) HAS_MKDOCS := $(shell command -v mkdocs;) -.PHONY: help build image cloudbuild-test cloudbuild clean +.PHONY: help build cloudbuild-test cloudbuild clean all: build install-mkdocs: ifndef HAS_MKDOCS - pip3 install mkdocs-material mkdocs-redirects + pip3 install mkdocs-material mkdocs-redirects mike endif help: ## Display this help @@ -36,9 +36,6 @@ release: ## Build distribution tarball @mkdir -p $(DIST_DIR) tar -jcf $(DIST_DIR)/$(PACKAGE)-$(VERSION).tar.bz2 -C $$(dirname $(SITE_OUTPUT_DIR)) $$(basename $(SITE_OUTPUT_DIR)) -image: ## Builds the container image - $(DOCKER) build -t $(IMAGE_REPO)/$(PACKAGE) -f Dockerfile . - clean: ## Clean build artifacts @$(RM) -v $(DIST_DIR)/$(PACKAGE)-$(VERSION).tar.bz2 @$(RM) -rv $(SITE_OUTPUT_DIR) diff --git a/docs/overrides/main.html b/docs/overrides/main.html index 74d9d879d..0d64eea34 100644 --- a/docs/overrides/main.html +++ b/docs/overrides/main.html @@ -11,3 +11,12 @@ Twitter {% endblock %} + +{% block outdated %} + You're not viewing the latest version. + + + + Click here to go to latest. + +{% endblock %} \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 4548483f4..154d44b01 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -203,6 +203,8 @@ theme: - navigation.tracking extra: + version: + provider: mike social: - icon: fontawesome/brands/github link: https://github.com/triggermesh