diff --git a/README.md b/README.md index b14bbab..9dac497 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,36 @@ with: - `npm_registry`: URL to the private NPM registry. Optional field. Defaults to `https://registrynpm.storefrontcloud.io`. - `version`: Version that will be used for docker image tag. Example: 2.3.0, 3.1.0-rc.1. If not passed, github.sha will be used +### build-stripe-ct + +```yaml +uses: vuestorefront/storefront-deployment/build-stripe-ct +with: + project_name: ${{ secrets.PROJECT_NAME }} + cloud_username: ${{ secrets.CLOUD_USERNAME }} + cloud_password: ${{ secrets.CLOUD_PASSWORD }} + docker_registry_url: 'registry.vuestorefront.cloud' + version: 2.3.0 +``` + +**Input Parameters:** + +- `project_name`: Project name in Console. Required field. +- `cloud_username`: Cloud API and Docker registry username. Required field. +- `cloud_password`: Cloud API and Docker registry password. Required field. +- `npm_email`: Email address required for logging into the private NPM registry. Required field. +- `npm_user`: Username for the private NPM registry. Required field. +- `npm_pass`: Password for the private NPM registry. Required field. +- `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`. +- `npm_registry`: URL to the private NPM registry. Optional field. Defaults to `https://registrynpm.storefrontcloud.io`. +- `version`: Version that will be used for docker image tag. Example: 2.3.0, 3.1.0-rc.1. If not passed, github.sha will be used +- `extension_module_name`: Extension module name. It’s used as the name of the docker image and path where the api is available. Default value is `ct-stripe-extension`. +- `extension_module_port`: Port of the extension module. Default value is `8080`. +- `extension_module_config`: Configuration for the extension module. Required field. +- `notification_module_name`: Notification module name. It’s used as the name of the docker image and path where the api is available. Default value is `ct-stripe-notification`. +- `notification_module_port`: Port of the notification module. Default value is `8081`. +- `notification_module_config`: Configuration for the notification module. Required field. + ### deploy ```yaml @@ -97,3 +127,31 @@ with: - `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`. - `console_api_url`: URL to the Console. Optional field. Defaults to `https://api.platform.vuestorefront.io`. - `version`: Docker image tag that will be deployed. Example: 2.3.0, 3.1.0-rc.1. If not passed, github.sha will be used + +### deploy/stripe-ct + +```yaml +uses: vuestorefront/storefront-deployment/deploy/stripe-ct +with: + project_name: ${{ secrets.PROJECT_NAME }} + cloud_username: ${{ secrets.CLOUD_USERNAME }} + cloud_password: ${{ secrets.CLOUD_PASSWORD }} + cloud_region: ${{ secrets.CLOUD_REGION }} + docker_registry_url: 'registry.vuestorefront.cloud' + console_api: 'https://api.platform.vuestorefront.io' + version: 2.3.0 +``` + +**Input Parameters:** + +- `project_name`: Project name in Console. Required field. +- `cloud_username`: Cloud API and Docker registry username. Required field. +- `cloud_password`: Cloud API and Docker registry password. Required field. +- `cloud_region`: Region where the environment is set up in the Console. Required field. +- `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`. +- `console_api_url`: URL to the Console. Optional field. Defaults to `https://api.platform.vuestorefront.io`. +- `version`: Docker image tag that will be deployed. Example: 2.3.0, 3.1.0-rc.1. If not passed, github.sha will be used +- `extension_module_name`: Extension module name. It’s used as the name of the docker image and path where the api is available. Default value is `ct-stripe-extension`. +- `extension_module_port`: Port of the extension module. Default value is `8080`. +- `notification_module_name`: Notification module name. It’s used as the name of the docker image and path where the api is available. Default value is `ct-stripe-notification`. +- `notification_module_port`: Port of the notification module. Default value is `8081`. \ No newline at end of file diff --git a/build-stripe-ct/action.yml b/build-stripe-ct/action.yml new file mode 100644 index 0000000..fead0fd --- /dev/null +++ b/build-stripe-ct/action.yml @@ -0,0 +1,104 @@ +name: Build Stripe CT Module +description: Builds Stripe CT module docker image +inputs: + project_name: + description: "Project name" + required: true + docker_registry_url: + description: "Docker registry url" + required: false + default: "registry.vuestorefront.cloud" + cloud_username: + description: "Cloud username" + required: true + cloud_password: + description: "Cloud password" + required: true + version: + description: "Version of the app" + required: false + extension_module_name: + description: "Stripe CT extension module name" + required: false + default: "ct-stripe-extension" + extension_module_port: + description: "Stripe CT extension module port" + required: false + default: "8080" + extension_module_config: + description: "Stripe CT extension module config" + required: true + notification_module_name: + description: "Stripe CT notification module name" + required: false + default: "ct-stripe-notification" + notification_module_port: + description: "Stripe CT notification module port" + required: false + default: "8081" + notification_module_config: + description: "Stripe CT notification module config" + required: true +runs: + using: "composite" + steps: + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Encode Basic Auth + id: base64-auth + shell: bash + run: | + echo "BASIC_AUTH_TOKEN=$(echo -n ${{ inputs.cloud_username }}:${{ inputs.cloud_password }} | base64 -w 0)" >> "$GITHUB_OUTPUT" + + # Extension module + - name: Check for existing docker image (${{ inputs.extension_module_name }}) + id: check-existing-image-for-extension + uses: javajawa/check-registry-for-image@v2 + with: + registry: ${{ inputs.docker_registry_url }} + auth: "Basic ${{ steps.base64-auth.outputs.BASIC_AUTH_TOKEN }}" + repository: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.extension_module_name }} + tag: ${{ inputs.version || github.sha }} + + - name: Build and publish docker image (${{ inputs.extension_module_name }}) + uses: elgohr/Publish-Docker-Github-Action@v5 + if: ${{ steps.check-existing-image-for-extension.outputs.exists == 'false' }} + with: + name: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.extension_module_name }}:${{ inputs.version || github.sha }} + registry: ${{ inputs.docker_registry_url }} + username: ${{ inputs.cloud_username }} + password: ${{ inputs.cloud_password }} + dockerfile: .vuestorefrontcloud/docker/${{ inputs.extension_module_name }}/Dockerfile + buildoptions: --compress + buildargs: INTEGRATION_CONFIG,INTEGRATION_PORT + env: + INTEGRATION_CONFIG: ${{ inputs.extension_module_config }} + INTEGRATION_PORT: ${{ inputs.extension_module_port }} + + # Notification module + - name: Check for existing docker image (${{ inputs.notification_module_name }}) + id: check-existing-image-for-notification + uses: javajawa/check-registry-for-image@v2 + with: + registry: ${{ inputs.docker_registry_url }} + auth: "Basic ${{ steps.base64-auth.outputs.BASIC_AUTH_TOKEN }}" + repository: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.notification_module_name }} + tag: ${{ inputs.version || github.sha }} + + - name: Build and publish docker image (${{ inputs.notification_module_name }}) + uses: elgohr/Publish-Docker-Github-Action@v5 + if: ${{ steps.check-existing-image-for-notification.outputs.exists == 'false' }} + with: + name: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.notification_module_name }}:${{ inputs.version || github.sha }} + registry: ${{ inputs.docker_registry_url }} + username: ${{ inputs.cloud_username }} + password: ${{ inputs.cloud_password }} + dockerfile: .vuestorefrontcloud/docker/${{ inputs.notification_module_name }}/Dockerfile + buildoptions: --compress + buildargs: INTEGRATION_CONFIG,INTEGRATION_PORT + env: + INTEGRATION_CONFIG: ${{ inputs.notification_module_config }} + INTEGRATION_PORT: ${{ inputs.notification_module_port }} diff --git a/deploy/action.yml b/deploy/action.yml index ae8902c..365f62e 100644 --- a/deploy/action.yml +++ b/deploy/action.yml @@ -1,28 +1,28 @@ name: Deploy Storefront -description: Builds Middleware app docker image +description: Deploy the Storefront to the Console inputs: project_name: - description: 'Project name' + description: "Project name" required: true docker_registry_url: - description: 'Docker registry url' + description: "Docker registry url" required: false - default: 'registry.vuestorefront.cloud' + default: "registry.vuestorefront.cloud" cloud_username: - description: 'Cloud username' + description: "Cloud username" required: true cloud_password: - description: 'Cloud password' + description: "Cloud password" required: true cloud_region: - description: 'Cloud region' + description: "Cloud region" required: true console_api_url: - description: 'URI for Vue Storefront Console API' + description: "URI for Vue Storefront Console API" required: false - default: 'https://api.platform.vuestorefront.io' + default: "https://api.platform.vuestorefront.io" version: - description: 'Version of the app' + description: "Version of the app" required: false runs: @@ -32,7 +32,7 @@ runs: name: Create GitHub deployment id: deployment with: - token: '${{ github.token }}' + token: "${{ github.token }}" environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io environment: production initial-status: in_progress @@ -50,9 +50,9 @@ runs: if: success() uses: chrnorm/deployment-status@releases/v2 with: - token: '${{ github.token }}' + token: "${{ github.token }}" environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io - state: 'success' + state: "success" description: Congratulations! The deploy is done. deployment-id: ${{ steps.deployment.outputs.deployment_id }} @@ -60,8 +60,8 @@ runs: if: failure() uses: chrnorm/deployment-status@releases/v2 with: - token: '${{ github.token }}' + token: "${{ github.token }}" environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io description: Unfortunately, the instance hasn't been updated. - state: 'failure' + state: "failure" deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/deploy/stripe-ct/action.yml b/deploy/stripe-ct/action.yml new file mode 100644 index 0000000..926e229 --- /dev/null +++ b/deploy/stripe-ct/action.yml @@ -0,0 +1,83 @@ +name: Deploy Stripe CT +description: Deploy Storefront with Stripe for Commercetools +inputs: + project_name: + description: "Project name" + required: true + docker_registry_url: + description: "Docker registry url" + required: false + default: "registry.vuestorefront.cloud" + cloud_username: + description: "Cloud username" + required: true + cloud_password: + description: "Cloud password" + required: true + cloud_region: + description: "Cloud region" + required: true + console_api_url: + description: "URI for Vue Storefront Console API" + required: false + default: "https://api.platform.vuestorefront.io" + version: + description: "Version of the app" + required: false + extension_module_name: + description: "Stripe CT extension module name" + required: false + default: "ct-stripe-extension" + extension_module_port: + description: "Stripe CT extension module port" + required: false + default: "8080" + notification_module_name: + description: "Stripe CT notification module name" + required: false + default: "ct-stripe-notification" + notification_module_port: + description: "Stripe CT notification module port" + required: false + default: "8081" + +runs: + using: "composite" + steps: + - uses: chrnorm/deployment-action@releases/v2 + name: Create GitHub deployment + id: deployment + with: + token: "${{ github.token }}" + environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io + environment: production + initial-status: in_progress + + - name: Deploy Storefront + Middleware + Stripe CT modules + uses: fjogeleit/http-request-action@v1 + with: + url: "${{ inputs.console_api_url }}/cloud/instances/${{ inputs.project_name }}-${{ inputs.cloud_region }}-gcp-storefrontcloud-io/deploy" + method: "PATCH" + customHeaders: '{"Content-Type":"application/json"}' + data: '{"cloudUserId":"${{ inputs.cloud_username }}","cloudUserPassword":"${{ inputs.cloud_password }}","dockerImageHash":"${{ inputs.version || github.sha }}","middlewareData":{"path":"/api/","port":4000,"has_base_path":false},"additionalApps":{"apps":{"commercetools-stripe-extension-module":{"name":"${{ inputs.extension_module_name }}","tag":"${{ inputs.version || github.sha }}","image":"${{ inputs.docker_registry_url }}/${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.extension_module_name }}","path":"/${{ inputs.extension_module_name }}/","port":"${{ inputs.extension_module_port }}","has_base_path":false},"commercetools-stripe-notification-module":{"name":"${{ inputs.notification_module_name }}","tag":"${{ inputs.version || github.sha }}","image":"${{ inputs.docker_registry_url }}/${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.notification_module_name }}","path":"/${{ inputs.notification_module_name }}/","port":"${{ inputs.notification_module_port }}","has_base_path":false}}}}' + timeout: 60000 + + - name: Update deployment status (success) + if: success() + uses: chrnorm/deployment-status@releases/v2 + with: + token: "${{ github.token }}" + environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.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/v2 + with: + token: "${{ github.token }}" + environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io + description: Unfortunately, the instance hasn't been updated. + state: "failure" + deployment-id: ${{ steps.deployment.outputs.deployment_id }}