Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: deploying canary - support (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored May 7, 2020
1 parent 5ec9126 commit 9e7e693
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 74 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/deploy-preview-storefrontcloud.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Deploy PR Preview on Storefrontcloud
on:
env:
CANARY_SW6_INSTANCE: https://shopware6-demo.vuestorefront.io
CANARY_SW6_INSTANCE_TOKEN: SWSCVJJET0RQAXFNBMTDZTV1OQ
INSTANCE_CODE: shopware-pwa-canary
on:
pull_request:
types: [opened, synchronize]

Expand All @@ -21,7 +25,7 @@ jobs:
run: |
mkdir test-project
cd ./test-project
../packages/cli/bin/shopware-pwa init --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode --stage local
../packages/cli/bin/shopware-pwa init --shopwareEndpoint=${{ env.CANARY_SW6_INSTANCE }} --shopwareAccessToken=${{ env.CANARY_SW6_INSTANCE_TOKEN }} --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode --stage local
yarn build
- name: Build and publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
Expand All @@ -48,14 +52,14 @@ jobs:
uses: mkucmus/storefrontcloud-preview-deploy@master
with:
token: "${{ github.token }}"
namespace: "shopware-pwa"
namespace: "${{env.INSTANCE_CODE}}"
- name: Comment PR
if: success()
uses: mkucmus/storefrontcloud-comment-pr-preview-deploy@master
with:
preview_url: '${{ steps.deploy.outputs.preview_url }}'
preview_url: "${{ steps.deploy.outputs.preview_url }}"
token: "${{ github.token }}"
namespace: 'shopware-pwa'
namespace: "${{env.INSTANCE_CODE}}"
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
Expand Down
34 changes: 15 additions & 19 deletions .github/workflows/deploy-storefrontcloud.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: Deploy to Storefrontcloud
on:
push:
branches:
- master
release:
types: [published]
env:
RELEASE_URL: https://shopware-pwa.storefrontcloud.io
INSTANCE_CODE: shopware-pwa

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: "12.x"
- name: Build packages
- name: Install shopware-pwa cli
run: |
yarn
yarn build --ci
- name: Create theme project
yarn global add @shopware-pwa/cli
- name: Create project (release)
run: |
mkdir test-project
cd ./test-project
../packages/cli/bin/shopware-pwa init --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode --stage local
shopware-pwa init --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode
yarn build
- name: Build and publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
Expand All @@ -41,23 +37,23 @@ jobs:
id: deployment
with:
token: "${{ github.token }}"
target_url: https://shopware-pwa.storefrontcloud.io
target_url: ${{ env.RELEASE_URL }}
environment: production
initial_status: in_progress
- name: Deploy on Storefrontcloud.io
run: |
if curl -s -u ${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"shopware-pwa","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then
if curl -s -u ${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"${{ env.INSTANCE_CODE }}","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..."
echo "Deployment failed"
exit 1
fi
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
target_url: https://shopware-pwa.storefrontcloud.io
target_url: ${{ env.RELEASE_URL }}
state: "success"
description: Congratulations! The deploy is done.
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
Expand All @@ -66,7 +62,7 @@ jobs:
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
target_url: https://shopware-pwa.storefrontcloud.io
target_url: ${{ env.RELEASE_URL }}
description: Unfortunately, the instance hasn't been updated.
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
46 changes: 0 additions & 46 deletions .github/workflows/deploy-zeit.yml

This file was deleted.

66 changes: 65 additions & 1 deletion .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
name: Publish canary
name: Publish & deploy canary version
env:
CANARY_SW6_INSTANCE: https://shopware6-demo.vuestorefront.io
CANARY_SW6_INSTANCE_TOKEN: SWSCVJJET0RQAXFNBMTDZTV1OQ
CANARY_URL: https://shopware-pwa-canary.storefrontcloud.io
INSTANCE_CODE: shopware-pwa-canary
on:
push:
branches:
Expand All @@ -24,3 +29,62 @@ jobs:
yarn lerna publish --canary --force-publish --yes --preid prealpha --dist-tag canary
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
build:
runs-on: ubuntu-latest
steps:
- name: Install shopware-pwa cli
run: |
yarn global add @shopware-pwa/cli@canary
- name: Create default-theme project
run: |
mkdir app
cd ./app
shopware-pwa init --shopwareEndpoint=${{ env.CANARY_SW6_INSTANCE }} --shopwareAccessToken=${{ env.CANARY_SW6_INSTANCE_TOKEN }} --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode --stage canary
yarn build
- name: Build and publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: shopware-pwa-storefrontcloud-io/vue-storefront:${{ github.sha }}
registry: registry.storefrontcloud.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
workdir: ./app
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: ${{ env.CANARY_URL }}
environment: canary
initial_status: in_progress
- name: Deploy on StorefrontCloud.io
run: |
if curl -s -u ${{ secrets.DOCKER_USERNAME }}:${{ secrets.DOCKER_PASSWORD }} -H 'Content-Type: application/json' -X POST -d '{"code":"${{ env.INSTANCE_CODE }}","frontContainerVersion":"${{ github.sha }}"}' https://farmer.storefrontcloud.io/instances | grep -q '{"code":200,"result":"Instance updated!"}'; then
echo "Instance updated"
else
echo "Deployment failed"
exit 1
fi
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@releases/v1
with:
token: "${{ github.token }}"
target_url: ${{ env.CANARY_URL }}
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: ${{ env.CANARY_URL }}
description: Unfortunately, the instance hasn't been updated.
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
2 changes: 1 addition & 1 deletion packages/composables/__tests__/useProductListing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("Composables - useProductListing", () => {
const { products, selectedFilters } = useProductListing([
{ product: "1" } as any,
]);
expect(selectedFilters.value).toStrictEqual({ categoryTree: [] });
expect(selectedFilters.value).toStrictEqual({});

expect(products.value).toHaveLength(1);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/composables/src/hooks/useProductListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const useProductListing = (
if (initialProducts.length) {
resetFilters();
resetSorting();
changePagination(1);
//changePagination(1);
}

const pagination: any = computed(() => localPagination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
},
},
setup({ content }) {
const propProducts = content.data.listing || []
const propProducts = content.data.listing.elements || []
const {
products,
changePagination,
Expand Down
1 change: 1 addition & 0 deletions test/test
Submodule test added at d1835f

1 comment on commit 9e7e693

@vercel
Copy link

@vercel vercel bot commented on 9e7e693 May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.