From 68b455565baec267af76d2a1d198c45e85f2fa77 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 8 Sep 2020 12:55:07 +0100 Subject: [PATCH] Update workflow file --- .github/workflows/ci.yml | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..9ac889fe9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,74 @@ +on: + pull_request: + push: + branches: + - master + - tiddlywiki-com +env: + 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" + # There's another near-duplicate "Set dynamic environment variables" step in + # the `build-tiddlywiki-com` job. + # These _could_ be extracted as a script (or moved into `ci-pre-build.sh`) to do away with the + # duplication, but, the visibility that comes from having these in the workflow file seems + # valuable. Environment variables are global variables and setting them at the top-level + # makes sense. + # Time to reconsider this decision might be when this setup turns out to be mistake-prone. + - name: "Set dynamic environment variables" + run: | + TW5_BUILD_BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + echo ::set-env name=TW5_BUILD_BRANCH::${TW5_BUILD_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 \'$TW5_BUILD_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.GITHUBPUSHTOKEN }} + 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" + # When making a change here, don't forget to see if it also applies to the step + # with the same name in the `build-prerelease` job. + - name: "Set dynamic environment variables" + run: | + TW5_BUILD_BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + echo ::set-env name=TW5_BUILD_BRANCH::${TW5_BUILD_BRANCH} + echo ::set-env name=TW5_BUILD_VERSION::$(./bin/get-plugin-library-version-number) + echo ::set-env name=TW5_BUILD_DETAILS::Built from branch \'$TW5_BUILD_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.GITHUBPUSHTOKEN }}