Trailing spaces - sync with main #100
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
# | |
# 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. | |
name: Build Attic site | |
# If the target branch is main, output is written to asf-site and cwiki-retired | |
# Otherwise, the generated output is written back to the branch so it can be checked | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
website: | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Checkout | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
with: | |
fetch-depth: 1 | |
- name: π Checkout asf-site branch with minimum depth | |
if: ${{ (github.head_ref || github.ref_name) == 'main' }} | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # 3.5.3 | |
with: | |
ref: asf-site | |
fetch-depth: 1 | |
path: asf-site | |
- name: π Checkout cwiki-retired branch with minimum depth | |
if: ${{ (github.head_ref || github.ref_name) == 'main' }} | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # 3.5.3 | |
with: | |
ref: cwiki-retired | |
fetch-depth: 1 | |
path: cwiki-retired | |
- name: Set up Ruby | |
# Although ubuntu-latest includes ruby 3.2.2, this step is needed to set up bundler | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.2.3 | |
bundler-cache: true | |
- name: π§ Build site | |
run: | | |
rm -rf asf-site/output/* | |
rm -rf cwiki-retired/* | |
ruby --version | |
bundle exec jekyll build -d asf-site/output | |
- name: Move cwiki-retired out of asf-site | |
if: ${{ (github.head_ref || github.ref_name) == 'main' }} | |
run: | | |
mv asf-site/output/cwiki_retired/* cwiki-retired | |
rm -rf asf-site/output/cwiki_retired | |
- name: π Add commit to the asf-site branch | |
if: ${{ (github.head_ref || github.ref_name) == 'main' }} | |
working-directory: asf-site | |
run: | | |
echo "Running git config" | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
echo "Running git add -A" | |
git add -A . | |
echo "Running git commit" | |
if git commit -m "Regenerated website based on ${GITHUB_SHA} commit" | |
then | |
git push origin asf-site | |
fi | |
- name: π Add commit to the cwiki-retired branch | |
if: ${{ (github.head_ref || github.ref_name) == 'main' }} | |
working-directory: cwiki-retired | |
run: | | |
echo "Running git config" | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
echo "Running git add -A" | |
git add -A . | |
echo "Running git commit" | |
if git commit -m "Regenerated website based on ${GITHUB_SHA} commit" | |
then | |
git push origin cwiki-retired | |
fi | |
- name: π Add commit to the branch (if not 'main') | |
if: ${{ (github.head_ref || github.ref_name) != 'main' }} | |
run: | | |
BRANCH="${{ (github.head_ref || github.ref_name) }}" | |
SITE="${{ (github.head_ref || github.ref_name) }}-site" | |
echo "branch: $BRANCH => site: $SITE" | |
echo "Running git config" | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
# ensure access to existing branches (i.e. allow for depth=1) | |
git fetch --tags -- origin +refs/heads/*:refs/remotes/origin/* | |
if git switch $SITE | |
then | |
echo "updating existing $SITE" | |
else | |
echo "creating orphan $SITE" | |
git switch --orphan $SITE | |
# Need gitignore | |
git checkout ${BRANCH} -- .gitignore | |
# create staging site | |
{ | |
echo "staging:" | |
echo " profile: $BRANCH" | |
echo " whoami: $SITE" | |
} >.asf.yaml | |
git add -A . | |
git commit -m "Init staging site $SITE" | |
git push --set-upstream origin $SITE | |
fi | |
rm -rf output | |
mv asf-site/output . | |
git add -f output # override .gitignore | |
rm -rf asf-site | |
echo "Running git add -A" | |
git add -A . | |
echo "Running git commit" | |
if git commit -m "Regenerated website based on ${GITHUB_SHA} commit" | |
then | |
git push | |
fi |