Migrate release of docs from travis-ci to github actions (#5162)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-02-24 19:41:22 -03:00 committed by GitHub
parent ceb721d6eb
commit 4a63609c3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 93 additions and 236 deletions

8
.github/actions/mkdocs/Dockerfile vendored Normal file
View file

@ -0,0 +1,8 @@
FROM squidfunk/mkdocs-material:4.6.3
COPY action.sh /action.sh
RUN apk add --no-cache bash \
&& chmod +x /action.sh
ENTRYPOINT ["/action.sh"]

53
.github/actions/mkdocs/action.sh vendored Normal file
View file

@ -0,0 +1,53 @@
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
REQUIREMENTS="${GITHUB_WORKSPACE}/requirements.txt"
if [ -f "${REQUIREMENTS}" ]; then
pip install -r "${REQUIREMENTS}"
fi
if [ -n "${GITHUB_TOKEN}" ]; then
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
elif [ -n "${PERSONAL_TOKEN}" ]; then
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
fi
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
mkdocs build --config-file "${GITHUB_WORKSPACE}/mkdocs.yml"
git clone --branch=gh-pages --depth=1 "${remote_repo}" gh-pages
cd gh-pages
# TODO: enable before release of helm chart
# copy current index file index.yaml before any change
#temp_worktree=$(mktemp -d)
#cp --force "index.yaml" "$temp_worktree/index.yaml"
# remove current content in branch gh-pages
git rm -r .
# copy new doc.
cp -r ../site/* .
# restore chart index
# TODO: enable before release of helm chart
#cp "$temp_worktree/index.yaml" .
# commit changes
git add .
git commit -m "Deploy GitHub Pages"
git push --force --quiet "${remote_repo}" gh-pages > /dev/null 2>&1

9
.github/actions/mkdocs/action.yml vendored Normal file
View file

@ -0,0 +1,9 @@
# action.yml
name: 'Deploy MkDocs'
description: 'Deploys MkDocs site'
branding:
icon: 'arrow-up-circle'
color: 'orange'
runs:
using: 'docker'
image: 'Dockerfile'

23
.github/workflows/main.yaml vendored Normal file
View file

@ -0,0 +1,23 @@
name: docs and Helm chart
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
#- name: Run chart-releaser
# uses: helm/chart-releaser-action@v1.0.0-alpha.2
# env:
# CR_TOKEN: "${{ secrets.PERSONAL_TOKEN }}"
- name: Deploy docs
uses: ./.github/actions/mkdocs
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}