-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added sample for Adobe Commerce Webhook (#8)
* Added webhooks code sample app. * Finished webhooks action process. * Changed webhook folder name. * devcontainer for running the solution * adds github actions to run webhook * stubs out a pr test for the sample extension * renames workflows for easier identification * adds a workflow readme * adds content to the readme * updates the path for the webhooks test action * adds static testing for api mesh directory * Finished webhooks sample unit tests and updated Readme. * Added Adobe license header and EOF empty line. * Removed unecessary web-src folder and updated readme file. * Adding EOF empty lines and updating webhooks readme file. * Removing unnecessary dependencies. --------- Co-authored-by: Gabriel Ranghetti <gabriel.ranghetti@toyota.com> Co-authored-by: Doug Hatcher <doug.hatcher@blueacornici.com>
- Loading branch information
1 parent
7155ad5
commit d241ce3
Showing
23 changed files
with
12,634 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "Adobe Commerce Samples", | ||
|
||
"image": "mcr.microsoft.com/devcontainers/base:jammy", | ||
"features": { | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"nodeGypDependencies": true, | ||
"version": "18", | ||
"nvmVersion": "latest" | ||
} | ||
}, | ||
|
||
"postCreateCommand": "npm install -g @adobe/aio-cli && aio telemetry yes && aio plugins:install @adobe/aio-cli-plugin-api-mesh" | ||
|
||
|
||
} |
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,12 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for more information: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
# https://containers.dev/guide/dependabot | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "devcontainers" | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
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,19 @@ | ||
# Github Actions | ||
|
||
This repository has several self-contained example projects that need to be regularly tested when modified. While some example projects have their own `.github` directory, this mono-repo needs a varient of these workflows to work in order to account for different directory structures and other changes. This directory houses these modified versions. | ||
|
||
## Github Actions Setup | ||
|
||
The following are the variables required for the github actions to execute correctly | ||
|
||
| Variable | Description | Default Value | | ||
|------------------------------|-----------------------------------------------------------------------------------------------|--------------------------------| | ||
| AIO_RUNTIME_NAMESPACE_STAGE | The namespace for the AIO runtime environment in the staging stage, used for isolating resources and configurations. | `aio-runtime-namespace-stage` | | ||
| CLIENTID_STAGE | The client identifier for the staging environment, used to authenticate API requests. | `client-id-stage` | | ||
| CLIENTSECRET_STAGE | The client secret for the staging environment, used in conjunction with the client ID to authenticate API requests. | `client-secret-stage` | | ||
| IMSORGID_STAGE | The IMS organization ID for the staging environment, used to identify the organization within the IMS system. | `ims-org-id-stage` | | ||
| SCOPES_STAGE | The OAuth scopes for the staging environment, defining the permissions granted to the application. | `read:scope-stage write:scope-stage` | | ||
| TECHNICALACCEMAIL_STAGE | The email address associated with the technical account for the staging environment, used for notifications and account recovery. | `tech-account-email-stage@example.com` | | ||
| TECHNICALACCID_STAGE | The identifier for the technical account in the staging environment, used for managing the technical user and associated resources. | `tech-account-id-stage` | | ||
|
||
Credentials like Technical Account Email can be found by adding an I/O Action Event to the App Builder workspace and then adding an `Oauth Server-to-server` credential, this will generate most of the credentials needed above. For anything else, within the workspace click `Download All` and copy the information from the json file. |
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,43 @@ | ||
name: API Mesh/Mock Response CI | ||
on: [pull_request, push] | ||
jobs: | ||
deploy: | ||
name: Lint | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
node-version: ['20'] | ||
os: [ubuntu-latest] | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare Context (Linux/macOS) | ||
if: runner.os != 'Windows' | ||
run: mv -f api-mesh/mock-response/* . | ||
- name: Prepare Context (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
$source = "api-mesh\mock-response\*" | ||
$destination = "." | ||
$files = Get-ChildItem -Path $source | ||
foreach ($file in $files) { | ||
$destPath = Join-Path -Path $destination -ChildPath $file.Name | ||
if (Test-Path -Path $destPath) { | ||
Remove-Item -Path $destPath -Recurse -Force | ||
} | ||
} | ||
Move-Item -Path $source -Destination $destination -Force | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: setup dependancies | ||
run: npm install -g eslint jsonlint | ||
- name: Lint JSON | ||
run: jsonlint *.json | ||
- name: Lint Js | ||
run: eslint *.js |
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,66 @@ | ||
name: Sample Extension CI | ||
|
||
on: [pull_request, push] | ||
jobs: | ||
test: | ||
name: Test PR | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
os: [macOS-latest, ubuntu-latest, windows-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare Context (Linux/macOS) | ||
if: runner.os != 'Windows' | ||
run: mv -f sample-extension/* . | ||
- name: Prepare Context (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
$source = "sample-extension\*" | ||
$destination = "." | ||
$files = Get-ChildItem -Path $source | ||
foreach ($file in $files) { | ||
$destPath = Join-Path -Path $destination -ChildPath $file.Name | ||
if (Test-Path -Path $destPath) { | ||
Remove-Item -Path $destPath -Recurse -Force | ||
} | ||
} | ||
Move-Item -Path $source -Destination $destination -Force | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install | ||
run: npm i | ||
- name: Setup CLI | ||
uses: adobe/aio-cli-setup-action@1.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
version: 10.x.x | ||
- name: Auth | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: oauth_sts | ||
CLIENTID: ${{ secrets.CLIENTID_STAGE }} | ||
CLIENTSECRET: ${{ secrets.CLIENTSECRET_STAGE }} | ||
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_STAGE }} | ||
TECHNICALACCOUNTEMAIL: ${{ secrets.TECHNICALACCEMAIL_STAGE }} | ||
IMSORGID: ${{ secrets.IMSORGID_STAGE }} | ||
SCOPES: ${{ secrets.SCOPES_STAGE }} | ||
- name: Build | ||
env: | ||
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_STAGE }} | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: build | ||
- name: Test | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: test |
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,66 @@ | ||
name: Webhooks CI | ||
|
||
on: [pull_request, push] | ||
jobs: | ||
test: | ||
name: Test PR | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node-version: ['20'] | ||
os: [macOS-latest, ubuntu-latest, windows-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare Context (Linux/macOS) | ||
if: runner.os != 'Windows' | ||
run: mv -f webhooks/add-to-cart-stock-validation/* . | ||
- name: Prepare Context (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
$source = "webhooks\add-to-cart-stock-validation\*" | ||
$destination = "." | ||
$files = Get-ChildItem -Path $source | ||
foreach ($file in $files) { | ||
$destPath = Join-Path -Path $destination -ChildPath $file.Name | ||
if (Test-Path -Path $destPath) { | ||
Remove-Item -Path $destPath -Recurse -Force | ||
} | ||
} | ||
Move-Item -Path $source -Destination $destination -Force | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install | ||
run: npm i | ||
- name: Setup CLI | ||
uses: adobe/aio-cli-setup-action@1.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
version: 10.x.x | ||
- name: Auth | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: oauth_sts | ||
CLIENTID: ${{ secrets.CLIENTID_STAGE }} | ||
CLIENTSECRET: ${{ secrets.CLIENTSECRET_STAGE }} | ||
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_STAGE }} | ||
TECHNICALACCOUNTEMAIL: ${{ secrets.TECHNICALACCEMAIL_STAGE }} | ||
IMSORGID: ${{ secrets.IMSORGID_STAGE }} | ||
SCOPES: ${{ secrets.SCOPES_STAGE }} | ||
- name: Build | ||
env: | ||
AIO_RUNTIME_NAMESPACE: ${{ secrets.AIO_RUNTIME_NAMESPACE_STAGE }} | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: build | ||
- name: Test | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: test |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
.vscode |
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,62 @@ | ||
name: CI | ||
# Controls when the workflow will run | ||
# on: | ||
# # Triggers the workflow on push or pull request events but only for the "main" branch | ||
# # push: | ||
# # branches: [ "main" ] | ||
# # pull_request: | ||
# # branches: [ "main" ] | ||
|
||
# # Allows you to run this workflow manually from the Actions tab | ||
# workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
deploy: | ||
name: Lint | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
node-version: ['20'] | ||
os: [ubuntu-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Setup CLI | ||
uses: adobe/aio-cli-setup-action@1.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
version: 10.x.x | ||
- name: api-mesh-plugin install | ||
run: aio plugins:install @adobe/aio-cli-plugin-api-mesh | ||
- name: Auth | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: oauth_sts | ||
CLIENTID: ${{ secrets.CLIENTID_PROD }} | ||
CLIENTSECRET: ${{ secrets.CLIENTSECRET_PROD }} | ||
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_PROD }} | ||
TECHNICALACCOUNTEMAIL: ${{ secrets.TECHNICALACCEMAIL_PROD }} | ||
IMSORGID: ${{ secrets.IMSORGID_PROD }} | ||
SCOPES: AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets | ||
- name: Select org | ||
run: aio console:org:select ${{ secrets.ORGID_PROD }} | ||
- name: Select project | ||
run: aio console:project:select ${{ secrets.PROJECTID_PROD }} | ||
- name: Select workspace | ||
run: aio console:workspace:select ${{ secrets.WORKSPACEID_PROD }} | ||
- name: 'Create env file' | ||
run: | | ||
touch .env | ||
echo API_ENDPOINT="https://xxx.execute-api.us-west-2.amazonaws.com" >> .env | ||
echo API_KEY=${{ secrets.API_KEY }} >> .env | ||
cat .env | ||
- name: api-mesh update | ||
run: aio api-mesh:update -c meshConfig.json --env .env |
63 changes: 63 additions & 0 deletions
63
api-mesh/mock-response/.github/workflows/pr_prod_deploy.yml
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,63 @@ | ||
name: CI | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
# push: | ||
# branches: [ "main" ] | ||
# pull_request: | ||
# branches: [ "main" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
deploy: | ||
name: Deploy to Prod | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
node-version: ['20'] | ||
os: [ubuntu-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Setup CLI | ||
uses: adobe/aio-cli-setup-action@1.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
version: 10.x.x | ||
- name: api-mesh-plugin install | ||
run: aio plugins:install @adobe/aio-cli-plugin-api-mesh | ||
- name: Auth | ||
uses: adobe/aio-apps-action@3.3.0 | ||
with: | ||
os: ${{ matrix.os }} | ||
command: oauth_sts | ||
CLIENTID: ${{ secrets.CLIENTID_PROD }} | ||
CLIENTSECRET: ${{ secrets.CLIENTSECRET_PROD }} | ||
TECHNICALACCOUNTID: ${{ secrets.TECHNICALACCID_PROD }} | ||
TECHNICALACCOUNTEMAIL: ${{ secrets.TECHNICALACCEMAIL_PROD }} | ||
IMSORGID: ${{ secrets.IMSORGID_PROD }} | ||
SCOPES: AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets | ||
- name: Select org | ||
run: aio console:org:select ${{ secrets.ORGID_PROD }} | ||
- name: Select project | ||
run: aio console:project:select ${{ secrets.PROJECTID_PROD }} | ||
- name: Select workspace | ||
run: aio console:workspace:select ${{ secrets.WORKSPACEID_PROD }} | ||
- name: 'Create env file' | ||
run: | | ||
touch .env | ||
echo API_ENDPOINT="https://xxx.execute-api.us-west-2.amazonaws.com" >> .env | ||
echo API_KEY=${{ secrets.API_KEY }} >> .env | ||
cat .env | ||
- name: api-mesh update | ||
run: aio api-mesh:update -c meshConfig.json --env .env |
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 @@ | ||
module.exports = {}; |
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,5 @@ | ||
{ | ||
"plugins": [ | ||
"@babel/plugin-transform-react-jsx" | ||
] | ||
} |
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,10 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:jest/recommended"], | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
} | ||
} |
Oops, something went wrong.