blob: 9166fe8c13d80cbe50b812f21711818f70541c48 [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
#
# 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: Deploy
on:
push:
branches:
- master
pull_request:
branches:
- "*"
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-ruby@v1
- name: Install dependencies
run: |
bundle install
- name: Build
run: |
if [ "${GITHUB_REPOSITORY}" = "apache/arrow-site" ]; then
# Production
BASE_URL=
else
# On a fork, so we'll deploy to GitHub Pages
BASE_URL=$(echo ${GITHUB_REPOSITORY} | sed -e 's@.*/@/@')
fi
JEKYLL_ENV=production \
bundle exec \
jekyll build \
--baseurl="${BASE_URL}" \
--destination=../build
- name: Deploy
run: |
if [ "${GITHUB_REPOSITORY}" = "apache/arrow-site" ]; then
# Production
TARGET_BRANCH=asf-site
else
# On a fork, so we'll deploy to GitHub Pages
TARGET_BRANCH=gh-pages
fi
git config user.name "$(git log -1 --pretty=format:%an)"
git config user.email "$(git log -1 --pretty=format:%ae)"
git remote add deploy \
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
if ! git checkout ${TARGET_BRANCH}; then
git checkout -b ${TARGET_BRANCH} remotes/origin/asf-site
fi
rsync \
-a \
--delete \
--exclude '/.git/' \
--exclude '/docs/' \
../build/ \
./
if [ "$(git status --porcelain)" != "" ]; then
# There are changes to the built site
git add --all
git commit -m "Updating built site (build ${GITHUB_SHA})"
git push deploy ${TARGET_BRANCH}
else
echo "No changes to the built site"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment GitHub Pages URL
uses: actions/github-script@0.2.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload;
const base_repo = payload.pull_request.base.repo;
const head_repo = payload.pull_request.head.repo;
const github_pages_url =
`https://${head_repo.owner.login}.github.io/${head_repo.name}/`;
const body = `${github_pages_url}\n${payload.after}`;
github.issues.createComment({
"owner": base_repo.owner.login,
"repo": base_repo.name,
"issue_number": payload.number,
"body": body
});
if: github.event_name == 'pull_request'