blob: 2fd2ecab2301cfafc920a8b0c1bd6e6876efec58 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
# https://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.
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
name: Deploy ASF site
on:
push:
branches:
- master
- branch-1.**
- "avro-3686-asf.yaml-docs"
tags-ignore:
- "release-**-rc**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-docs:
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set variables
id: variables
run: |
set -x
VERSION=$(cat share/VERSION.txt)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "target-branch=site-$VERSION" >> $GITHUB_OUTPUT
echo "baseUrl=docs-new/$VERSION" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install NPM dependencies
run: |
set -x
cd doc
npm install
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 0.108.0
extended: true
- name: Build docs
run: |
set -x
cd doc
hugo --minify --destination ../website --baseURL=/${{ steps.variables.outputs.baseUrl }}
- name: Copy & push the generated HTML
run: |
# TODO build the C/C++/C# docs for master/staging
set -x
sed -i -e "s|TARGET_BRANCH|${{ steps.variables.outputs.target-branch }}|" .asf.yaml
sed -i -e "s|SUBDIR|${{ steps.variables.outputs.baseUrl }}|" .asf.yaml
cp .asf.yaml website/
git checkout -B ${{ steps.variables.outputs.target-branch }}
# delete anything but: 1) '.'; 2) '..'; 3) .git/; 4) website/
find ./ | grep -vE "^./$|^../$|^./.git|^./website" | xargs rm -rf
mv website/* .
mv website/.asf.yaml .
ls -la website/
rmdir website
# TODO copy the C/C++/C# docs for master/staging
if [ "$(git status --porcelain)" != "" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add --all
git commit -m 'Publish built docs triggered by ${{ github.sha }}'
git push --set-upstream origin ${{ steps.variables.outputs.target-branch }} --force
fi