Skip to content

Commit

Permalink
Port Travis script to Github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Aug 9, 2023
1 parent f76012e commit 393b149
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 32 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and publish

on:
workflow_dispatch:
push:
branches: [ website ]

jobs:
publish:
name: Publish website on daisy.github.io/pipeline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache gems
uses: actions/cache@v3
with:
path: gems
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7.2'
- name: Install dependencies
run: bundle install --path gems
- name: Build
run: make
- name: Publish
if: ${{ github.event_name == 'push' && github.repository =='daisy/pipeline' && github.ref == 'refs/heads/website'}}
env:
GH_REMOTE: "https://${{ secrets.PUBLISH_WEBSITE_GITHUB_TOKEN }}@github.com/daisy/pipeline.git"
GH_USER_NAME: "Github CI"
GH_USER_EMAIL: "[email protected]"
run: |
make publish
# make publish-wiki
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .travis/publish.sh

This file was deleted.

Binary file removed .travis/secrets/deploy_key.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org' do
ruby '>= 2.3.3'
ruby '>= 2.7.2'
gem 'jekyll', '4.2.0'
gem 'rdf', '3.1.15'
gem 'rdf-xsd', '3.1.1'
Expand Down
10 changes: 9 additions & 1 deletion make/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ test -z "$(git status . --porcelain)"
GIT_HASH=$( git rev-parse HEAD )
WORKING_DIR=$(pwd)
SITE_DIR=$1
GH_REMOTE="[email protected]:daisy/pipeline.git"
if [ "x$GH_REMOTE" = "x" ]; then
GH_REMOTE="[email protected]:daisy/pipeline.git"
fi
GH_BRANCH=gh-pages
TMP_DIR=$( mktemp -t "$(basename "$0").XXXXXX" )
rm $TMP_DIR
Expand All @@ -14,6 +16,12 @@ cd $TMP_DIR
git rm -r *
cp -r $WORKING_DIR/$SITE_DIR/* .
git add .
if [ "x$GH_USER_NAME" != "x" ]; then
git config user.name "$GH_USER_NAME"
fi
if [ "x$GH_USER_EMAIL" != "x" ]; then
git config user.email "$GH_USER_EMAIL"
fi
git commit -m "publish site [ commit ${GIT_HASH} ]"
git push $GH_REMOTE $GH_BRANCH:$GH_BRANCH
cd $WORKING_DIR
Expand Down

0 comments on commit 393b149

Please sign in to comment.