You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2019/09/17 20:50:02 UTC
[arrow-site] branch master updated: ARROW-6569: [Website] Add
support for auto deployment by GitHub Actions (#24)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-site.git
The following commit(s) were added to refs/heads/master by this push:
new 1b7c985 ARROW-6569: [Website] Add support for auto deployment by GitHub Actions (#24)
1b7c985 is described below
commit 1b7c98535379f22f18435eec01a03ed0f62806d5
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Wed Sep 18 05:49:58 2019 +0900
ARROW-6569: [Website] Add support for auto deployment by GitHub Actions (#24)
* ARROW-6569: [Website] Add support for auto deployment by GitHub Actions
This may have an issue for GitHub Pages deploy for forks. But this
will be fixed by GitHub:
https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/td-p/26869
* Remove all automatic deployment description in README
Because we don't need to do nothing for automatic deployment.
This change also adds a comment hook to show preview URL. Then we
also don't need to describe where is preview URL in README.
* Comment
---
.github/workflows/deploy.yml | 100 +++++++++++++++++++++++++++++++++++++++++++
.travis.yml | 4 --
README.md | 84 ++----------------------------------
build-and-deploy.sh | 60 --------------------------
4 files changed, 103 insertions(+), 145 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..9166fe8
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,100 @@
+# 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'
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 998c0bd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-language: ruby
-cache: bundler
-
-script: ./build-and-deploy.sh
diff --git a/README.md b/README.md
index fb0a96e..dcaf279 100644
--- a/README.md
+++ b/README.md
@@ -68,91 +68,13 @@ Run the following to generate HTML files and run the web site locally.
bundle exec jekyll serve
```
-## Automatic deployment
-
-If you're working on a fork of `apache/arrow-site`, you can get a development
-version of the site built off of your `master` branch published using GitHub
-Pages and Travis-CI. There are a couple of quick steps to enable this:
-
-1. Create a `gh-pages` branch on your fork, based on the `asf-site` branch
-(`git checkout asf-site && git checkout -b gh-pages && git push origin gh-pages`)
-2. In the settings for your fork (https://github.com/$YOU/arrow-site/settings),
-turn on GitHub Pages and set it to the gh-pages branch
-3. Go to https://travis-ci.org/account/repositories and enable Travis builds on
-your fork
-4. Set up an auth token or deploy key:
-
-### With a personal access token:
-
-A GitHub personal access token takes the least effort to set up, but its scope
-is broader (all public repositories you have access to), so some may be worried
-about setting one in Travis (even though Travis encrypts them).
-
-1. Go to https://github.com/settings/tokens and create a GitHub personal access
-token with `public_repo` scope
-2. In the settings in Travis for your fork
-(https://travis-ci.org/$YOU/arrow-site/settings), add an environment variable
-called GITHUB_PAT, using the token you just created. To keep the token value
-secret, **do not toggle on "Display value in build log"** (i.e. the default is
-secret).
-
-### With a deploy key
-
-GitHub deploy keys are tied to a repository, so they have much narrower scope
-and aren't connected to an individual contributor, but they take a little more
-work to set up.
-
-1. On your computer, do `ssh-keygen -t rsa -b 4096 -f 'github_deploy_key' -N ''`
-2. Go to https://github.com/$YOU/arrow-site/settings/keys and put the public
-key there (found in `github_deploy_key.pub`). Check the box to give the token
-write access.
-3. In the settings in Travis for your fork
-(https://travis-ci.org/$YOU/arrow-site/settings), add an environment variable
-called DEPLOY_KEY. This takes the contents of the private key file you just
-made (`github_deploy_key`), but you have to preprocess it to escape whitespace.
-Replace the spaces ` ` in the first and last lines with `\ ` (i.e. the first
-line becomes `-----BEGIN\ OPENSSH\ PRIVATE\ KEY-----`), and replace the
-newlines with `\\n`. The result should be a very long string on a single line.
-To keep this ssh key value secret, **do not toggle on "Display value in build
-log"** (i.e. the default is secret).
-
-After doing this, commits to the master branch of your fork will be
-automatically built and published to https://$YOU.github.io/arrow-site/. This
-can help Arrow committers preview your changes more easily before accepting
-patches.
-
-## Publishing
-
-Publishing the site happens automatically on commits to the `master` branch on
-`apache/arrow-site`. Alternatively, to build and publish locally, clone the
-`arrow-site` repository again as a subdirectory:
-
-```shell
-git clone --branch=asf-site https://github.com/apache/arrow-site.git asf-site
-```
-
-To build and copy the contents of the built site to that second clone,
-
-```shell
-JEKYLL_ENV=production bundle exec jekyll build
-rsync -r build/ asf-site/
-cd asf-site
-git status
-```
-
-Now `git add` any new files, then commit everything, and push:
-
-```
-git push
-```
-
-### Updating Code Documentation
+## Updating Code Documentation
To update the documentation, you can run the script `./dev/gen_apidocs.sh` in
the `apache/arrow` repository. This script will run the code documentation
tools in a fixed environment.
-#### C (GLib)
+### C (GLib)
First, build Apache Arrow C++ and Apache Arrow GLib. This assumes that you have checkouts your forks of `arrow` and `arrow-site` alongside each other in your file system.
@@ -171,7 +93,7 @@ LD_LIBRARY_PATH=$PWD/../cpp/build/debug make GTK_DOC_V_XREF=": "
rsync -r doc/reference/html/ ../../arrow-site/asf-site/docs/c_glib/
```
-#### Javascript
+### JavaScript
```
cd ../js
diff --git a/build-and-deploy.sh b/build-and-deploy.sh
deleted file mode 100755
index 80e56f7..0000000
--- a/build-and-deploy.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-set -ev
-
-if [ "${TRAVIS_BRANCH}" = "master" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
-
- if [ "${GITHUB_PAT}" = "" ] && [ "${DEPLOY_KEY}" = "" ]; then
- # Don't build because we can't publish
- echo "To publish the site, you must set a GITHUB_PAT or DEPLOY_KEY at"
- echo "https://travis-ci.org/${TRAVIS_REPO_SLUG}/settings"
- exit 1
- fi
-
- # Set git config so that the author of the deployed site commit is the same
- # as the author of the commit we're building
- AUTHOR_EMAIL=$(git log -1 --pretty=format:%ae)
- AUTHOR_NAME=$(git log -1 --pretty=format:%an)
- git config --global user.email "${AUTHOR_EMAIL}"
- git config --global user.name "${AUTHOR_NAME}"
-
- if [ "${TRAVIS_REPO_SLUG}" = "apache/arrow-site" ]; then
- # Production
- TARGET_BRANCH=asf-site
- BASE_URL=
- else
- # On a fork, so we'll deploy to GitHub Pages
- TARGET_BRANCH=gh-pages
- # You could supply an alternate BASE_URL, but that's not necessary
- # because we can infer it based on GitHub Pages conventions
- if [ "${BASE_URL}" = "" ]; then
- BASE_URL=$(echo $TRAVIS_REPO_SLUG | sed -e 's@.*/@/@')
- fi
- fi
-
- # Build
- JEKYLL_ENV=production bundle exec jekyll build --baseurl="${BASE_URL}"
-
- # Publish
- if [ "${DEPLOY_KEY}" != "" ]; then
- echo "Setting deploy key"
- eval $(ssh-agent -s)
- # Hack to make the key from the env var have real newlines
- echo "${DEPLOY_KEY}" | sed -e 's/\\n/\n/g' | ssh-add -
- git clone -b ${TARGET_BRANCH} git@github.com:$TRAVIS_REPO_SLUG.git OUTPUT
- else
- echo "Using GitHub PAT"
- git clone -b ${TARGET_BRANCH} https://${GITHUB_PAT}@github.com/$TRAVIS_REPO_SLUG.git OUTPUT
- fi
-
- rsync -a --delete --exclude '/.git/' --exclude '/docs/' build/ OUTPUT/
- cd OUTPUT
-
- if [ "$(git status --porcelain)" != "" ]; then
- # There are changes to the built site
- git add .
- git commit -m "Updating built site (build ${TRAVIS_BUILD_NUMBER})"
- git push origin ${TARGET_BRANCH}
- else
- echo "No changes to the built site"
- fi
-fi