Skip to content

ATTIC-246 Retire griffin (#25) #174

ATTIC-246 Retire griffin (#25)

ATTIC-246 Retire griffin (#25) #174

Workflow file for this run

# 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, output site is written to $branch-site branch that is staged to https://attic-$branch.staged.apache.org/ for review
on:
push:
# only build main on push. This is to avoid double builds on PRs and consequent failures.
branches:
- main
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 cwiki flags based on ${GITHUB_SHA} commit"
then
git push origin cwiki-retired
fi
- name: πŸš€ Add commit to the site staging *-site branch
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 = https://attic-$BRANCH.staged.apache.org/"
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
echo "https://attic-$BRANCH.staged.apache.org/\n\nbuilt from \`$BRANCH\` branch https://github.com/apache/attic/tree/$BRANCH" > README.md
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