-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci(ES-665): add stripe-ct action * ci: build and deploy actions * update gh actions * Apply suggestions from code review Co-authored-by: Mateusz Gostański <[email protected]> * apply review feedback * refactor * fix build action * fix deploy action * fix deploy tags * fix build step outputs * fix build envs * update readme * Apply suggestions from code review Co-authored-by: Mateusz Gostański <[email protected]> --------- Co-authored-by: Mateusz Gostański <[email protected]>
- Loading branch information
1 parent
91b3ec6
commit b48b7f3
Showing
4 changed files
with
260 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |