From a206dccf0a26a8d5a05a0c7dec35dba3a95f80b2 Mon Sep 17 00:00:00 2001 From: ento Date: Fri, 28 Aug 2020 08:31:57 -0800 Subject: [PATCH] Add GitHub Actions workflow (#4793) * Parameterize strings that mention Travis This is so that the script can be shared with GitHub Actions while we make the transition. * Add GitHub Actions workflow More or less a direct translation of .travis.yml * Rename scripts that mention travis * Fix typo --- .github/workflows/ci.yml | 70 ++++++++++++++++++++ .travis.yml | 10 +-- bin/{travis-pre-build.sh => ci-pre-build.sh} | 0 bin/ci-push.sh | 20 ++++++ bin/travis-push.sh | 20 ------ 5 files changed, 95 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/ci.yml rename bin/{travis-pre-build.sh => ci-pre-build.sh} (100%) create mode 100755 bin/ci-push.sh delete mode 100755 bin/travis-push.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..055007dc7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +on: + pull_request: + push: + branches: + - master + - tiddlywiki-com +env: + COMMIT_CONTEXT: "GitHub build" + COMMIT_EMAIL: "actions@github.com" + COMMIT_NAME: "GitHub Actions" + NODE_VERSION: "12" +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE_VERSION }}" + - run: "./bin/test.sh" + build-prerelease: + runs-on: ubuntu-latest + if: github.ref == "refs/heads/master" + needs: test + env: + TW5_BUILD_TIDDLYWIKI: "./tiddlywiki.js" + TW5_BUILD_MAIN_EDITION: "./editions/prerelease" + TW5_BUILD_OUTPUT: "./output/prerelease" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE_VERSION }}" + - run: "./bin/ci-pre-build.sh" + - name: "Set dynamic environment variables" + run: | + TRAVIS_BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + echo ::set-env name=TRAVIS_BRANCH::${TRAVIS_BRANCH} + echo ::set-env name=TW5_BUILD_VERSION::$(./bin/get-plugin-library-version-number) + echo ::set-env name=TW5_BUILD_DETAILS::Prerelease built from branch \'$TRAVIS_BRANCH\' at commit $(git rev-parse HEAD) of $(git remote get-url origin) at $(date +'%F %T %Z') + - run: "./bin/build-site.sh" + - run: "./bin/ci-push.sh" + env: + GH_TOKEN: ${{ secrets.GITHUB_PUSH_TOKEN }} + TRAVIS_BUILD_NUMBER: ${{ github.run_number }} + build-tiddlywiki-com: + runs-on: ubuntu-latest + if: github.ref == "refs/heads/tiddlywiki-com" + needs: test + env: + TW5_BUILD_TIDDLYWIKI: "./node_modules/tiddlywiki/tiddlywiki.js" + TW5_BUILD_MAIN_EDITION: "./editions/tw5.com" + TW5_BUILD_OUTPUT: "./output" + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: "${{ env.NODE_VERSION }}" + - run: "./bin/ci-pre-build.sh" + - name: "Set dynamic environment variables" + run: | + TRAVIS_BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + echo ::set-env name=TRAVIS_BRANCH::${TRAVIS_BRANCH} + echo ::set-env name=TW5_BUILD_VERSION::$(./bin/get-plugin-library-version-number) + echo ::set-env name=TW5_BUILD_DETAILS::Built from branch \'$TRAVIS_BRANCH\' at commit $(git rev-parse HEAD) of $(git remote get-url origin) at $(date +'%F %T %Z') + - run: "./bin/build-site.sh" + - run: "./bin/ci-push.sh" + env: + GH_TOKEN: ${{ secrets.GITHUB_PUSH_TOKEN }} + TRAVIS_BUILD_NUMBER: ${{ github.run_number }} diff --git a/.travis.yml b/.travis.yml index 95199ed75..b714cf477 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,27 +9,27 @@ stages: - name: build-tiddlywiki-com if: branch = "tiddlywiki-com" AND type = push AND fork = false -jobs: +jobs: include: - stage: test script: ./bin/test.sh - stage: build-prerelease script: - - ./bin/travis-pre-build.sh + - ./bin/ci-pre-build.sh - export TW5_BUILD_TIDDLYWIKI='./tiddlywiki.js' - export TW5_BUILD_VERSION=$(./bin/get-plugin-library-version-number) - export TW5_BUILD_DETAILS="Prerelease built from branch '$TRAVIS_BRANCH' at commit $(git rev-parse HEAD) of $(git remote get-url origin) at $(date +'%F %T %Z')" - export TW5_BUILD_MAIN_EDITION='./editions/prerelease' - export TW5_BUILD_OUTPUT='./output/prerelease' - ./bin/build-site.sh || travis_terminate 1 - - ./bin/travis-push.sh || travis_terminate 1 + - ./bin/ci-push.sh || travis_terminate 1 - stage: build-tiddlywiki-com script: - - ./bin/travis-pre-build.sh + - ./bin/ci-pre-build.sh - export TW5_BUILD_TIDDLYWIKI='./node_modules/tiddlywiki/tiddlywiki.js' - export TW5_BUILD_VERSION=$(./bin/get-plugin-library-version-number) - export TW5_BUILD_DETAILS="Built from branch '$TRAVIS_BRANCH' at commit $(git rev-parse HEAD) of $(git remote get-url origin) at $(date +'%F %T %Z')" - export TW5_BUILD_MAIN_EDITION='./editions/tw5.com' - export TW5_BUILD_OUTPUT='./output' - ./bin/build-site.sh || travis_terminate 1 - - ./bin/travis-push.sh || travis_terminate 1 + - ./bin/ci-push.sh || travis_terminate 1 diff --git a/bin/travis-pre-build.sh b/bin/ci-pre-build.sh similarity index 100% rename from bin/travis-pre-build.sh rename to bin/ci-pre-build.sh diff --git a/bin/ci-push.sh b/bin/ci-push.sh new file mode 100755 index 000000000..97a06e64e --- /dev/null +++ b/bin/ci-push.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Push output back to GitHub + + +cd output || exit 1 + +git config --global user.email "${COMMIT_EMAIL:-travis@travis-ci.org}" || exit 1 + +git config --global user.name "${COMMIT_NAME:-Travis CI}" || exit 1 + +git add -A . || exit 1 + +git commit --message "${COMMIT_CONTEXT:-Travis build}: $TRAVIS_BUILD_NUMBER of $TRAVIS_BRANCH ($(date +'%F %T %Z'))" || exit 1 + +git remote add deploy "https://$GH_TOKEN@github.com/Jermolene/jermolene.github.io.git" &>/dev/null || exit 1 + +git push deploy master &>/dev/null || exit 1 + +cd .. || exit 1 diff --git a/bin/travis-push.sh b/bin/travis-push.sh deleted file mode 100755 index aa16cd73c..000000000 --- a/bin/travis-push.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Push output back to GitHub - - -cd output || exit 1 - -git config --global user.email "travis@travis-ci.org" || exit 1 - -git config --global user.name "Travis CI" || exit 1 - -git add -A . || exit 1 - -git commit --message "Travis build: $TRAVIS_BUILD_NUMBER of $TRAVIS_BRANCH ($(date +'%F %T %Z'))" || exit 1 - -git remote add deploy "https://$GH_TOKEN@github.com/Jermolene/jermolene.github.io.git" &>/dev/null || exit 1 - -git push deploy master &>/dev/null || exit 1 - -cd .. || exit 1