diff --git a/.github/workflows/deploy-preview-storefrontcloud.yml b/.github/workflows/deploy-preview-storefrontcloud.yml new file mode 100644 index 000000000..690c398aa --- /dev/null +++ b/.github/workflows/deploy-preview-storefrontcloud.yml @@ -0,0 +1,66 @@ +name: Deploy PR Preview on Storefrontcloud +on: + pull_request: + types: [opened, synchronize] +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 and publish docker image + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: vsf-next-demo-storefrontcloud-io/vue-storefront:${{ github.sha }} + registry: registry.storefrontcloud.io + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_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 }}" + environment: preview + initial_status: in_progress + - name: Deploy on Storefrontcloud.io + id: deploy + uses: storefrontcloud/storefrontcloud-preview-deploy@0.1.0 + with: + token: "${{ github.token }}" + namespace: "vsf-next-demo" + username: ${{ secrets.CLOUD_USERNAME }} + password: ${{ secrets.CLOUD_PASSWORD }} + - name: Comment PR + if: success() + uses: storefrontcloud/storefrontcloud-comment-pr-preview-deploy@master + with: + preview_url: '${{ steps.deploy.outputs.preview_url }}' + token: "${{ github.token }}" + namespace: 'vsf-next-demo' + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: ${{ steps.deploy.outputs.preview_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 }}" + description: Unfortunately, the instance hasn't been updated. + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} \ No newline at end of file diff --git a/.github/workflows/deploy-storefrontcloud.yml b/.github/workflows/deploy-storefrontcloud.yml new file mode 100644 index 000000000..4859d1983 --- /dev/null +++ b/.github/workflows/deploy-storefrontcloud.yml @@ -0,0 +1,62 @@ +name: Deploy to Storefrontcloud +on: + push: + branches: + - master +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 and publish docker image + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: vsf-next-demo-storefrontcloud-io/vue-storefront:${{ github.sha }} + registry: registry.storefrontcloud.io + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_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://vsf-next-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":"vsf-next-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://vsf-next-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://vsf-next-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 diff --git a/.travis.yml b/.travis.yml index e1c7688f5..e22034683 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,21 +92,22 @@ jobs: # - stage: lighthouse # name: commercetools # script: lhci autorun --rc-overrides.upload.target=temporary-public-storage --collect.startServerCommand="yarn start:ct" --collect.url=http://localhost:3000 --collect.startServerReadyPattern="Listening" + + # - build_image: + # if: type = pull_request + # name: "Build docker image" + # stage: docker build + # script: + # - docker build --build-arg COMMIT -t registry.storefrontcloud.io/vsf-next-demo-storefrontcloud-io/vue-storefront:$COMMIT -f dev/docker/Dockerfile . + # - echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USERNAME" --password-stdin registry.storefrontcloud.io + # - docker push registry.storefrontcloud.io/vsf-next-demo-storefrontcloud-io/vue-storefront:$COMMIT + # - curl $COMMIT.vsf-next-demo.preview.storefrontcloud.io + # - echo "This commit preview is available here $COMMIT.vsf-next-demo.preview.storefrontcloud.io" + + # - deploy_to_storefrontcloud: + # if: branch = master AND type != pull_request + # name: "Deploy to StorefrontCloud" + # stage: deploy + # script: + # - "curl -u $CLOUD_USERNAME:$CLOUD_PASSWORD -H 'Content-Type: application/json' -X POST -d \"{\\\"code\\\":\\\"vsf-next-demo\\\", \\\"frontContainerVersion\\\":\\\"$COMMIT\\\"}\" https://farmer.storefrontcloud.io/instances" - - build_image: - if: branch = master AND type != pull_request - name: "Build docker image" - stage: docker build - script: - - docker build --build-arg COMMIT -t registry.storefrontcloud.io/vsf-next-demo-storefrontcloud-io/vue-storefront:$COMMIT -f dev/docker/Dockerfile . - - echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USERNAME" --password-stdin registry.storefrontcloud.io - - docker push registry.storefrontcloud.io/vsf-next-demo-storefrontcloud-io/vue-storefront:$COMMIT - - curl $COMMIT.vsf-next-demo.preview.storefrontcloud.io - - echo "This commit preview is available here $COMMIT.vsf-next-demo.preview.storefrontcloud.io" - - - deploy_to_storefrontcloud: - if: branch = master AND type != pull_request - name: "Deploy to StorefrontCloud" - stage: deploy - script: - - "curl -u $CLOUD_USERNAME:$CLOUD_PASSWORD -H 'Content-Type: application/json' -X POST -d \"{\\\"code\\\":\\\"vsf-next-demo\\\", \\\"frontContainerVersion\\\":\\\"$COMMIT\\\"}\" https://farmer.storefrontcloud.io/instances" diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index e3fc6c7a7..2b0b6a2d1 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -14,4 +14,6 @@ RUN yarn install \ COPY dev/docker/vue-storefront.sh /usr/local/bin/ +EXPOSE 3000 + ENTRYPOINT ["vue-storefront.sh"]