Migrate release of docs from travis-ci to github actions (#5162)
This commit is contained in:
parent
ceb721d6eb
commit
4a63609c3e
8 changed files with 93 additions and 236 deletions
8
.github/actions/mkdocs/Dockerfile
vendored
Normal file
8
.github/actions/mkdocs/Dockerfile
vendored
Normal 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
53
.github/actions/mkdocs/action.sh
vendored
Normal 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
9
.github/actions/mkdocs/action.yml
vendored
Normal 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
23
.github/workflows/main.yaml
vendored
Normal 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 }}
|
34
.travis.yml
34
.travis.yml
|
@ -1,34 +0,0 @@
|
|||
dist: bionic
|
||||
|
||||
sudo: required
|
||||
|
||||
language: generic
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_failure: always
|
||||
on_success: never
|
||||
|
||||
before_install:
|
||||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
- curl -fsSL https://get.docker.com | sh
|
||||
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
|
||||
- mkdir -p $HOME/.docker
|
||||
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
|
||||
- sudo service docker start
|
||||
|
||||
# New secure variables can be added using travis encrypt -r kubernetes/ingress-nginx --add K=V
|
||||
env:
|
||||
global:
|
||||
- GH_REF=github.com/kubernetes/ingress-nginx
|
||||
- secure: LIS2XpZufWTcJ53jiRsSZy2Gi1EUJ1XmLg7z3f2ZHeMnyG2Jhk3GW4vod1FNru+PY4PWgddLdCdIl+jqOYXndFlbdAWF3/Oy5fEkYLXdYV7tdlHcPWDkqNFrfiyZ4guChN+b2Nk6FqU7o5fsZAIR7VAbgqNRF5XMo9Mhn/vhDCQRcnbXy7uq7JTrYUkqDbQoyYvT6b480GCY5gags1zp/xZfPDNZEe936o8i5IPTyiykRyNOXN/AH6kd3pR5e1xYgcvJ9KpSVPghcwFE7kJ4fOVMRhRG5ML+IyML+xD0jX43EMNoqRKZ/HS42kIMCInFbJEcxVde7DPNBZ7Y3GAqh7HO6qrE70Dn3ha6DID6zCoH2ArW39BxG4zempjn2VxYoMRGREyZszWQb++dwGoHmo5FHt6zvIrYBG0dA0H8ja9VkZkjFwtYTGHU1ooPzUfJK4O4VBayV8LqZibyZQR+GrmyQc0aagUY7J/fe4A2PJyI4DbkeZ7GX1ELj0ciDz4urQSzUc8l/T3aU3X+FuJItjgYtMLPmqcjA5uifDCtutE8Z9L2gSpanqUdvLSOozuxPho/KNl+2YlF7fXqPW3LnRf5mHD+NbOff306pvKlHJOb2Vm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KHbCSAw=
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: Publish docs
|
||||
if: type = api AND branch = master AND repo = kubernetes/ingress-nginx AND env(COMPONENT) = "docs"
|
||||
script:
|
||||
- .travis/publish-docs.sh
|
|
@ -1,90 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2017 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.
|
||||
|
||||
if ! [ -z $DEBUG ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
if [ -z $ARCH ]; then
|
||||
echo "Environment variable ARCH is not defined. Aborting.";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
echo "COMPONENT: $COMPONENT"
|
||||
echo "PLATFORM: $ARCH"
|
||||
echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
|
||||
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
|
||||
echo "TRAVIS_EVENT_TYPE: $TRAVIS_EVENT_TYPE"
|
||||
echo "TRAVIS_PULL_REQUEST_BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Check if jq binary is installed
|
||||
if ! [ -x "$(command -v jq)" ]; then
|
||||
echo "Installing jq..."
|
||||
sudo apt-get install -y jq
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_REPO_SLUG" != "kubernetes/ingress-nginx" ];
|
||||
then
|
||||
echo "Only builds from kubernetes/ingress-nginx repository is allowed.";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
SKIP_MESSAGE="Publication of docker image to quay.io registry skipped."
|
||||
|
||||
if [ "$TRAVIS_EVENT_TYPE" != "api" ];
|
||||
then
|
||||
echo "Only builds triggered from travis-ci API is allowed. $SKIP_MESSAGE";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ];
|
||||
then
|
||||
echo "This is a pull request. $SKIP_MESSAGE";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST_BRANCH" != "" ];
|
||||
then
|
||||
echo "Only images build from master branch are allowed. $SKIP_MESSAGE";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# variables QUAY_USERNAME and QUAY_PASSWORD are required to push docker images
|
||||
if [ "$QUAY_USERNAME" == "" ];
|
||||
then
|
||||
echo "Environment variable QUAY_USERNAME is missing.";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
if [ "$QUAY_PASSWORD" == "" ];
|
||||
then
|
||||
echo "Environment variable QUAY_PASSWORD is missing.";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
function docker_tag_exists() {
|
||||
TAG=${2//\"/}
|
||||
IMAGES=$(curl -s -H "Authorization: Bearer ${QUAY_PASSWORD}" https://quay.io/api/v1/repository/$1-$3/image/ | jq '.images | sort_by(.sort_index) | .[] .tags | select(.[] !=null) | .[0]' | sed s/\"//g)
|
||||
if echo "$IMAGES" | grep -q -P "(^|\s)$TAG(?=\s|$)" ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2018 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 -o errexit
|
||||
set -o pipefail
|
||||
|
||||
if ! [ -z $DEBUG ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ "$COMPONENT" != "docs" ]; then
|
||||
echo "This task runs only to publish docs"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
make -C ${DIR}/.. build-docs
|
||||
|
||||
git config --global user.email "travis@travis-ci.com"
|
||||
git config --global user.name "Travis Bot"
|
||||
|
||||
git clone --branch=gh-pages --depth=1 https://${GH_REF} ${DIR}/gh-pages
|
||||
cd ${DIR}/gh-pages
|
||||
|
||||
git rm -r .
|
||||
|
||||
cp -r ${DIR}/../site/* .
|
||||
|
||||
git add .
|
||||
git commit -m "Deploy GitHub Pages"
|
||||
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" gh-pages > /dev/null 2>&1
|
|
@ -1,67 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2017 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.
|
||||
|
||||
if ! [ -z $DEBUG ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
if [ "$TRAVIS_CI_TOKEN" == "" ];
|
||||
then
|
||||
echo "Environment variable TRAVIS_CI_TOKEN is missing.";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
function publish() {
|
||||
|
||||
body=$(cat <<EOF
|
||||
{
|
||||
"request": {
|
||||
"branch": "master",
|
||||
"message": "Publishing image for component $2 to quay.io",
|
||||
"config": {
|
||||
"merge_mode": "deep_merge",
|
||||
"env": {
|
||||
"matrix" : {
|
||||
"COMPONENT": "$2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Travis-API-Version: 3" \
|
||||
-H "Authorization: token $1" \
|
||||
--data "$body" \
|
||||
https://api.travis-ci.org/repo/kubernetes%2Fingress-nginx/requests
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
ingress-controller|nginx|docs)
|
||||
publish $TRAVIS_CI_TOKEN $1
|
||||
;;
|
||||
*)
|
||||
echo "Invalid publish option"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
Loading…
Reference in a new issue