From 24600565da15fb582d7b937f5f5bac9394b40790 Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 12:39:06 +0200 Subject: [PATCH 1/6] [WIP] GH Actions --- .github/workflows/deploy-storefrontcloud.yml | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/deploy-storefrontcloud.yml diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml new file mode 100644 index 0000000000..a525272897 --- /dev/null +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -0,0 +1,63 @@ +name: Deploy to Storefrontcloud +on: + push: + branches: + - master + - feature/gh_actions +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v1 + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: "10.x" + - name: Build and publish docker image + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: demo-storefrontcloud-io/vue-storefront:${{ github.sha }} + registry: registry.storefrontcloud.io + username: ${{ secrets.CLOUD_USERNAME }} + password: ${{ secrets.CLOUD_PASSWORD }} + dockerfile: dev/docker/Dockerfile + buildoptions: "--compress" + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - uses: chrnorm/deployment-action@releases/v1 + name: Create GitHub deployment + id: deployment + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + environment: production + initial_status: in_progress + - name: Deploy on Storefrontcloud.io + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"demo","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + state: "success" + description: Congratulations! The deploy is done. + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (failure) + if: failure() + uses: chrnorm/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://demo.storefrontcloud.io + description: Unfortunately, the instance hasn't been updated. + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} \ No newline at end of file From 71f73497920ff194e587c8daeda12c356a38d6e8 Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 12:48:21 +0200 Subject: [PATCH 2/6] [WIP] GHA added docker file for cloud --- dev/docker/Dockerfile | 19 +++++++++++++++++++ dev/docker/vue-storefront.sh | 8 ++++++++ 2 files changed, 27 insertions(+) create mode 100644 dev/docker/Dockerfile create mode 100644 dev/docker/vue-storefront.sh diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile new file mode 100644 index 0000000000..2464bb9170 --- /dev/null +++ b/dev/docker/Dockerfile @@ -0,0 +1,19 @@ +FROM node:10 + +ENV NODE_CONFIG_ENV=docker PM2_ARGS=--no-daemon BIND_HOST=0.0.0.0 VS_ENV=prod + +WORKDIR /var/www + +COPY . . + +# Should be yarn install --production +RUN apt update && apt install -y git \ + && yarn install \ + && yarn build:client \ + && yarn build:server \ + && yarn build:sw + +COPY dev/docker/vue-storefront.sh /usr/local/bin/ +RUN chmod a+x /usr/local/bin/vue-storefront.sh + +ENTRYPOINT ["vue-storefront.sh"] diff --git a/dev/docker/vue-storefront.sh b/dev/docker/vue-storefront.sh new file mode 100644 index 0000000000..4413dc3c06 --- /dev/null +++ b/dev/docker/vue-storefront.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +if [ "$VS_ENV" = 'dev' ]; then + yarn dev +else + yarn start +fi From c0054114c06f62e856361b4a29b0b461d91d3d9a Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 13:09:38 +0200 Subject: [PATCH 3/6] [WIP] Test for next --- .github/workflows/deploy-storefrontcloud.yml | 12 +++++++++++- config/default.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml index a525272897..3d8c103aec 100644 --- a/.github/workflows/deploy-storefrontcloud.yml +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -35,7 +35,8 @@ jobs: target_url: https://demo.storefrontcloud.io environment: production initial_status: in_progress - - name: Deploy on Storefrontcloud.io + - name: Deploy on demo.storefrontcloud.io + if: github.ref == 'master' run: | if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"demo","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then echo "Instance updated" @@ -43,6 +44,15 @@ jobs: echo "Something went wrong during the update process..." exit 1 fi + - name: Deploy on demo.storefrontcloud.io + if: github.ref == 'feature/gh_actions' + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"next","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi - name: Update deployment status (success) if: success() uses: chrnorm/deployment-status@releases/v1 diff --git a/config/default.json b/config/default.json index f23130cdf7..7b8083e976 100644 --- a/config/default.json +++ b/config/default.json @@ -17,7 +17,7 @@ "invalidateCacheKey": "aeSu7aip", "invalidateCacheForwarding": false, "invalidateCacheForwardUrl": "http://localhost:8080/invalidate?key=aeSu7aip&tag=", - "dynamicConfigReload": false, + "dynamicConfigReload": true, "dynamicConfigContinueOnError": false, "dynamicConfigExclude": ["ssr", "storeViews", "entities", "localForage", "shipping", "boost", "query"], "dynamicConfigInclude": [], From bd95e371c18e3189147bd931984a3dd4ffd88510 Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 13:25:16 +0200 Subject: [PATCH 4/6] [WIP] Test for branches --- .github/workflows/deploy-storefrontcloud.yml | 26 +++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml index 3d8c103aec..e10fdebb69 100644 --- a/.github/workflows/deploy-storefrontcloud.yml +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -3,6 +3,8 @@ on: push: branches: - master + - develop + - hotfix/v* - feature/gh_actions jobs: build: @@ -36,7 +38,7 @@ jobs: environment: production initial_status: in_progress - name: Deploy on demo.storefrontcloud.io - if: github.ref == 'master' + if: github.ref == 'refs/heads/master' run: | if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"demo","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then echo "Instance updated" @@ -44,8 +46,26 @@ jobs: echo "Something went wrong during the update process..." exit 1 fi - - name: Deploy on demo.storefrontcloud.io - if: github.ref == 'feature/gh_actions' + - name: Deploy on next.storefrontcloud.io + if: contains(github.ref, 'hotfix/v') + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"next","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Deploy on test.storefrontcloud.io + if: github.ref == 'refs/heads/develop' + run: | + if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"test","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then + echo "Instance updated" + else + echo "Something went wrong during the update process..." + exit 1 + fi + - name: Deploy on next for test + if: github.ref == 'refs/heads/feature/gh_actions' run: | if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"next","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then echo "Instance updated" From c961a81f5767ee3cec4d8d7b2b8387dff1ec832a Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 14:04:14 +0200 Subject: [PATCH 5/6] Removed test steps --- .github/workflows/deploy-storefrontcloud.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml index e10fdebb69..ccc4bb8f29 100644 --- a/.github/workflows/deploy-storefrontcloud.yml +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -5,7 +5,6 @@ on: - master - develop - hotfix/v* - - feature/gh_actions jobs: build: runs-on: ubuntu-latest @@ -64,15 +63,6 @@ jobs: echo "Something went wrong during the update process..." exit 1 fi - - name: Deploy on next for test - if: github.ref == 'refs/heads/feature/gh_actions' - run: | - if curl -s -u ${{ secrets.CLOUD_USERNAME }}:${{ secrets.CLOUD_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"next","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then - echo "Instance updated" - else - echo "Something went wrong during the update process..." - exit 1 - fi - name: Update deployment status (success) if: success() uses: chrnorm/deployment-status@releases/v1 From 68cb6744ad1cbb4ada4818ef5a29ae5d88a846af Mon Sep 17 00:00:00 2001 From: mkoszutowski Date: Wed, 15 Apr 2020 14:13:00 +0200 Subject: [PATCH 6/6] yarn build instead of fwe yarn build:* --- dev/docker/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 2464bb9170..528a855b84 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -9,9 +9,7 @@ COPY . . # Should be yarn install --production RUN apt update && apt install -y git \ && yarn install \ - && yarn build:client \ - && yarn build:server \ - && yarn build:sw + && yarn build COPY dev/docker/vue-storefront.sh /usr/local/bin/ RUN chmod a+x /usr/local/bin/vue-storefront.sh