From c9104dbe324ba9683b6ee33304b73e27ffb83e81 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 10 Jun 2020 21:35:04 +0200 Subject: [PATCH] Docker build/push ... try #1 --- .github/workflows/push-master.yml | 14 ++++++++++- scripts/docker.sh | 40 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 scripts/docker.sh diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 1bd49913c9..de231807f6 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -31,6 +31,19 @@ jobs: yarn install --immutable | grep -v 'YN0013' yarn ${{ matrix.step }} + # only run on "CI skip", i.e. when the actual version has been bumped to release/stable + docker: + name: docker + if: "startsWith(github.event.head_commit.message, '[CI Skip] release/') && github.repository == 'polkadot-js/apps'" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: docker + env: + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: | + ./scripts/docker.sh + # only run on "CI skip", i.e. when the actual version has been bumped to release/stable electron: strategy: @@ -49,7 +62,6 @@ jobs: run: | mkdir -p ~/private_keys/ echo '${{ secrets.API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.API_KEY_ID }}.p8 - - name: Build/release Electron app uses: samuelmeuli/action-electron-builder@v1 with: diff --git a/scripts/docker.sh b/scripts/docker.sh new file mode 100644 index 0000000000..a3d82b1987 --- /dev/null +++ b/scripts/docker.sh @@ -0,0 +1,40 @@ +#!/user/bin/env bash +# Copyright 2017-2020 @polkadot/apps authors & contributors +# This software may be modified and distributed under the terms +# of the Apache-2.0 license. See the LICENSE file for details. + +# fail fast on any non-zero exits +set -e + +# the docker image name and dockerhub repo +NAME="polkadot-js-apps" +REPO="jacogr" + +# extract the current npm version from package.json +VERSION=$(cat package.json \ + | grep version \ + | head -1 \ + | awk -F: '{ print $2 }' \ + | sed 's/[",]//g' \ + | sed 's/ //g') + +# helper function for the build logic +function build () { + echo "*** Building $NAME" + docker build -t $NAME . +} + +# helper function for the publishing logic +function publish () { + docker login -u $REPO -p $DOCKER_PASS + + echo "*** Tagging $REPO/$NAME" + docker tag $NAME $REPO/$NAME:$VERSION + docker tag $NAME $REPO/$NAME + + echo "*** Publishing $NAME" + docker push $REPO/$NAME +} + +build +publish