diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..e9bfabbec6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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: "daisy@users.noreply.github.com" + run: | + make publish + # make publish-wiki diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d763470a2e..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -install: - - bundle install --path gems -script: - - make -after_success: - - source .travis/publish.sh -cache: - directories: - - gems diff --git a/.travis/publish.sh b/.travis/publish.sh deleted file mode 100644 index cee06d03a8..0000000000 --- a/.travis/publish.sh +++ /dev/null @@ -1,21 +0,0 @@ -# ssh-keygen -t rsa -b 4096 -C 'noreply@travis-ci.org' -f .travis/secrets/deploy_key -# travis encrypt-file --repo daisy/pipeline .travis/secrets/deploy_key -# mv deploy_key.enc .travis/secrets -# rm .travis/secrets/deploy_key -# rm .travis/secrets/deploy_key.pub -# git add .travis/secrets/deploy_key.enc - -if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "website" ]; then - echo "Skipping deployment" - exit 0 -else - openssl aes-256-cbc -K $encrypted_0ca289d261f6_key -iv $encrypted_0ca289d261f6_iv \ - -in .travis/secrets/deploy_key.enc -out .travis/secrets/deploy_key -d && \ - chmod 600 .travis/secrets/deploy_key && \ - eval `ssh-agent -s` && \ - ssh-add .travis/secrets/deploy_key && \ - git config --global user.name "travis-ci" && \ - git config --global user.email "noreply@travis-ci.org" && \ - make publish - make publish-wiki -fi diff --git a/.travis/secrets/deploy_key.enc b/.travis/secrets/deploy_key.enc deleted file mode 100644 index 0db3dd5b69..0000000000 Binary files a/.travis/secrets/deploy_key.enc and /dev/null differ diff --git a/Gemfile b/Gemfile index 76868a4960..a7785d4403 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/make/publish.sh b/make/publish.sh index 669f41c676..8b742e6269 100755 --- a/make/publish.sh +++ b/make/publish.sh @@ -5,7 +5,9 @@ test -z "$(git status . --porcelain)" GIT_HASH=$( git rev-parse HEAD ) WORKING_DIR=$(pwd) SITE_DIR=$1 -GH_REMOTE="git@github.com:daisy/pipeline.git" +if [ "x$GH_REMOTE" = "x" ]; then + GH_REMOTE="git@github.com:daisy/pipeline.git" +fi GH_BRANCH=gh-pages TMP_DIR=$( mktemp -t "$(basename "$0").XXXXXX" ) rm $TMP_DIR @@ -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