Skip to content

Commit b48b7f3

Browse files
ci(ES-665): stripe ct actions (#20)
* 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]>
1 parent 91b3ec6 commit b48b7f3

File tree

4 files changed

+260
-15
lines changed

4 files changed

+260
-15
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ with:
7474
- `npm_registry`: URL to the private NPM registry. Optional field. Defaults to `https://registrynpm.storefrontcloud.io`.
7575
- `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
7676

77+
### build-stripe-ct
78+
79+
```yaml
80+
uses: vuestorefront/storefront-deployment/build-stripe-ct
81+
with:
82+
project_name: ${{ secrets.PROJECT_NAME }}
83+
cloud_username: ${{ secrets.CLOUD_USERNAME }}
84+
cloud_password: ${{ secrets.CLOUD_PASSWORD }}
85+
docker_registry_url: 'registry.vuestorefront.cloud'
86+
version: 2.3.0
87+
```
88+
89+
**Input Parameters:**
90+
91+
- `project_name`: Project name in Console. Required field.
92+
- `cloud_username`: Cloud API and Docker registry username. Required field.
93+
- `cloud_password`: Cloud API and Docker registry password. Required field.
94+
- `npm_email`: Email address required for logging into the private NPM registry. Required field.
95+
- `npm_user`: Username for the private NPM registry. Required field.
96+
- `npm_pass`: Password for the private NPM registry. Required field.
97+
- `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`.
98+
- `npm_registry`: URL to the private NPM registry. Optional field. Defaults to `https://registrynpm.storefrontcloud.io`.
99+
- `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
100+
- `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`.
101+
- `extension_module_port`: Port of the extension module. Default value is `8080`.
102+
- `extension_module_config`: Configuration for the extension module. Required field.
103+
- `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`.
104+
- `notification_module_port`: Port of the notification module. Default value is `8081`.
105+
- `notification_module_config`: Configuration for the notification module. Required field.
106+
77107
### deploy
78108

79109
```yaml
@@ -97,3 +127,31 @@ with:
97127
- `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`.
98128
- `console_api_url`: URL to the Console. Optional field. Defaults to `https://api.platform.vuestorefront.io`.
99129
- `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
130+
131+
### deploy/stripe-ct
132+
133+
```yaml
134+
uses: vuestorefront/storefront-deployment/deploy/stripe-ct
135+
with:
136+
project_name: ${{ secrets.PROJECT_NAME }}
137+
cloud_username: ${{ secrets.CLOUD_USERNAME }}
138+
cloud_password: ${{ secrets.CLOUD_PASSWORD }}
139+
cloud_region: ${{ secrets.CLOUD_REGION }}
140+
docker_registry_url: 'registry.vuestorefront.cloud'
141+
console_api: 'https://api.platform.vuestorefront.io'
142+
version: 2.3.0
143+
```
144+
145+
**Input Parameters:**
146+
147+
- `project_name`: Project name in Console. Required field.
148+
- `cloud_username`: Cloud API and Docker registry username. Required field.
149+
- `cloud_password`: Cloud API and Docker registry password. Required field.
150+
- `cloud_region`: Region where the environment is set up in the Console. Required field.
151+
- `docker_registry_url`: URL to the Docker image registry. Optional field. Defaults to `registry.vuestorefront.cloud`.
152+
- `console_api_url`: URL to the Console. Optional field. Defaults to `https://api.platform.vuestorefront.io`.
153+
- `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
154+
- `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`.
155+
- `extension_module_port`: Port of the extension module. Default value is `8080`.
156+
- `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`.
157+
- `notification_module_port`: Port of the notification module. Default value is `8081`.

build-stripe-ct/action.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Build Stripe CT Module
2+
description: Builds Stripe CT module docker image
3+
inputs:
4+
project_name:
5+
description: "Project name"
6+
required: true
7+
docker_registry_url:
8+
description: "Docker registry url"
9+
required: false
10+
default: "registry.vuestorefront.cloud"
11+
cloud_username:
12+
description: "Cloud username"
13+
required: true
14+
cloud_password:
15+
description: "Cloud password"
16+
required: true
17+
version:
18+
description: "Version of the app"
19+
required: false
20+
extension_module_name:
21+
description: "Stripe CT extension module name"
22+
required: false
23+
default: "ct-stripe-extension"
24+
extension_module_port:
25+
description: "Stripe CT extension module port"
26+
required: false
27+
default: "8080"
28+
extension_module_config:
29+
description: "Stripe CT extension module config"
30+
required: true
31+
notification_module_name:
32+
description: "Stripe CT notification module name"
33+
required: false
34+
default: "ct-stripe-notification"
35+
notification_module_port:
36+
description: "Stripe CT notification module port"
37+
required: false
38+
default: "8081"
39+
notification_module_config:
40+
description: "Stripe CT notification module config"
41+
required: true
42+
runs:
43+
using: "composite"
44+
steps:
45+
- name: Setup node
46+
uses: actions/setup-node@v3
47+
with:
48+
node-version: 18.x
49+
50+
- name: Encode Basic Auth
51+
id: base64-auth
52+
shell: bash
53+
run: |
54+
echo "BASIC_AUTH_TOKEN=$(echo -n ${{ inputs.cloud_username }}:${{ inputs.cloud_password }} | base64 -w 0)" >> "$GITHUB_OUTPUT"
55+
56+
# Extension module
57+
- name: Check for existing docker image (${{ inputs.extension_module_name }})
58+
id: check-existing-image-for-extension
59+
uses: javajawa/check-registry-for-image@v2
60+
with:
61+
registry: ${{ inputs.docker_registry_url }}
62+
auth: "Basic ${{ steps.base64-auth.outputs.BASIC_AUTH_TOKEN }}"
63+
repository: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.extension_module_name }}
64+
tag: ${{ inputs.version || github.sha }}
65+
66+
- name: Build and publish docker image (${{ inputs.extension_module_name }})
67+
uses: elgohr/Publish-Docker-Github-Action@v5
68+
if: ${{ steps.check-existing-image-for-extension.outputs.exists == 'false' }}
69+
with:
70+
name: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.extension_module_name }}:${{ inputs.version || github.sha }}
71+
registry: ${{ inputs.docker_registry_url }}
72+
username: ${{ inputs.cloud_username }}
73+
password: ${{ inputs.cloud_password }}
74+
dockerfile: .vuestorefrontcloud/docker/${{ inputs.extension_module_name }}/Dockerfile
75+
buildoptions: --compress
76+
buildargs: INTEGRATION_CONFIG,INTEGRATION_PORT
77+
env:
78+
INTEGRATION_CONFIG: ${{ inputs.extension_module_config }}
79+
INTEGRATION_PORT: ${{ inputs.extension_module_port }}
80+
81+
# Notification module
82+
- name: Check for existing docker image (${{ inputs.notification_module_name }})
83+
id: check-existing-image-for-notification
84+
uses: javajawa/check-registry-for-image@v2
85+
with:
86+
registry: ${{ inputs.docker_registry_url }}
87+
auth: "Basic ${{ steps.base64-auth.outputs.BASIC_AUTH_TOKEN }}"
88+
repository: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.notification_module_name }}
89+
tag: ${{ inputs.version || github.sha }}
90+
91+
- name: Build and publish docker image (${{ inputs.notification_module_name }})
92+
uses: elgohr/Publish-Docker-Github-Action@v5
93+
if: ${{ steps.check-existing-image-for-notification.outputs.exists == 'false' }}
94+
with:
95+
name: ${{ inputs.project_name }}-storefrontcloud-io/${{ inputs.notification_module_name }}:${{ inputs.version || github.sha }}
96+
registry: ${{ inputs.docker_registry_url }}
97+
username: ${{ inputs.cloud_username }}
98+
password: ${{ inputs.cloud_password }}
99+
dockerfile: .vuestorefrontcloud/docker/${{ inputs.notification_module_name }}/Dockerfile
100+
buildoptions: --compress
101+
buildargs: INTEGRATION_CONFIG,INTEGRATION_PORT
102+
env:
103+
INTEGRATION_CONFIG: ${{ inputs.notification_module_config }}
104+
INTEGRATION_PORT: ${{ inputs.notification_module_port }}

deploy/action.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
name: Deploy Storefront
2-
description: Builds Middleware app docker image
2+
description: Deploy the Storefront to the Console
33
inputs:
44
project_name:
5-
description: 'Project name'
5+
description: "Project name"
66
required: true
77
docker_registry_url:
8-
description: 'Docker registry url'
8+
description: "Docker registry url"
99
required: false
10-
default: 'registry.vuestorefront.cloud'
10+
default: "registry.vuestorefront.cloud"
1111
cloud_username:
12-
description: 'Cloud username'
12+
description: "Cloud username"
1313
required: true
1414
cloud_password:
15-
description: 'Cloud password'
15+
description: "Cloud password"
1616
required: true
1717
cloud_region:
18-
description: 'Cloud region'
18+
description: "Cloud region"
1919
required: true
2020
console_api_url:
21-
description: 'URI for Vue Storefront Console API'
21+
description: "URI for Vue Storefront Console API"
2222
required: false
23-
default: 'https://api.platform.vuestorefront.io'
23+
default: "https://api.platform.vuestorefront.io"
2424
version:
25-
description: 'Version of the app'
25+
description: "Version of the app"
2626
required: false
2727

2828
runs:
@@ -32,7 +32,7 @@ runs:
3232
name: Create GitHub deployment
3333
id: deployment
3434
with:
35-
token: '${{ github.token }}'
35+
token: "${{ github.token }}"
3636
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
3737
environment: production
3838
initial-status: in_progress
@@ -50,18 +50,18 @@ runs:
5050
if: success()
5151
uses: chrnorm/deployment-status@releases/v2
5252
with:
53-
token: '${{ github.token }}'
53+
token: "${{ github.token }}"
5454
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
55-
state: 'success'
55+
state: "success"
5656
description: Congratulations! The deploy is done.
5757
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
5858

5959
- name: Update deployment status (failure)
6060
if: failure()
6161
uses: chrnorm/deployment-status@releases/v2
6262
with:
63-
token: '${{ github.token }}'
63+
token: "${{ github.token }}"
6464
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
6565
description: Unfortunately, the instance hasn't been updated.
66-
state: 'failure'
66+
state: "failure"
6767
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

deploy/stripe-ct/action.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy Stripe CT
2+
description: Deploy Storefront with Stripe for Commercetools
3+
inputs:
4+
project_name:
5+
description: "Project name"
6+
required: true
7+
docker_registry_url:
8+
description: "Docker registry url"
9+
required: false
10+
default: "registry.vuestorefront.cloud"
11+
cloud_username:
12+
description: "Cloud username"
13+
required: true
14+
cloud_password:
15+
description: "Cloud password"
16+
required: true
17+
cloud_region:
18+
description: "Cloud region"
19+
required: true
20+
console_api_url:
21+
description: "URI for Vue Storefront Console API"
22+
required: false
23+
default: "https://api.platform.vuestorefront.io"
24+
version:
25+
description: "Version of the app"
26+
required: false
27+
extension_module_name:
28+
description: "Stripe CT extension module name"
29+
required: false
30+
default: "ct-stripe-extension"
31+
extension_module_port:
32+
description: "Stripe CT extension module port"
33+
required: false
34+
default: "8080"
35+
notification_module_name:
36+
description: "Stripe CT notification module name"
37+
required: false
38+
default: "ct-stripe-notification"
39+
notification_module_port:
40+
description: "Stripe CT notification module port"
41+
required: false
42+
default: "8081"
43+
44+
runs:
45+
using: "composite"
46+
steps:
47+
- uses: chrnorm/deployment-action@releases/v2
48+
name: Create GitHub deployment
49+
id: deployment
50+
with:
51+
token: "${{ github.token }}"
52+
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
53+
environment: production
54+
initial-status: in_progress
55+
56+
- name: Deploy Storefront + Middleware + Stripe CT modules
57+
uses: fjogeleit/http-request-action@v1
58+
with:
59+
url: "${{ inputs.console_api_url }}/cloud/instances/${{ inputs.project_name }}-${{ inputs.cloud_region }}-gcp-storefrontcloud-io/deploy"
60+
method: "PATCH"
61+
customHeaders: '{"Content-Type":"application/json"}'
62+
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}}}}'
63+
timeout: 60000
64+
65+
- name: Update deployment status (success)
66+
if: success()
67+
uses: chrnorm/deployment-status@releases/v2
68+
with:
69+
token: "${{ github.token }}"
70+
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
71+
state: "success"
72+
description: Congratulations! The deploy is done.
73+
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
74+
75+
- name: Update deployment status (failure)
76+
if: failure()
77+
uses: chrnorm/deployment-status@releases/v2
78+
with:
79+
token: "${{ github.token }}"
80+
environment-url: https://${{ inputs.project_name }}.${{ inputs.cloud_region }}.gcp.storefrontcloud.io
81+
description: Unfortunately, the instance hasn't been updated.
82+
state: "failure"
83+
deployment-id: ${{ steps.deployment.outputs.deployment_id }}

0 commit comments

Comments
 (0)