Skip to content

Commit

Permalink
feat: demo deployment action (#30)
Browse files Browse the repository at this point in the history
New GitHub Action that will build and push our demo.

## Demo patch

A patch containing all changes between develop and the
current demo branch has been generated:
```
$ git diff develop..demo --binary > algolia-demo.patch
```

## Workflow

The GitHub Action will:
- Checkout the `develop` branch (`${{ github.ref_name }}` points on the
branch that triggered the workflow
([doc](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables)))
- Generate the `algolia-config.json` and `commerce-api-config.json`
files using `jq` to inject variables and secrets from env vars (c.f. [jq
doc](https://jqlang.github.io/jq/manual/#$env-env)).
- Apply the `algolia-demo.patch`
- Build and push the bundle

---
SFCC-384
  • Loading branch information
sbellone authored Oct 14, 2024
1 parent 9d9de58 commit 5b6d7ef
Show file tree
Hide file tree
Showing 3 changed files with 13,656 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy demo

on:
workflow_dispatch:
# push:
# branches: [ "develop" ]

jobs:
deploy_demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Generate algolia-config.json
env:
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY: ${{ vars.ALGOLIA_API_KEY }}
run: |
jq '.appId = env.ALGOLIA_APP_ID | .apiKey = env.ALGOLIA_API_KEY' config/algolia-config.example.json > config/algolia-config.json
- name: Generate commerce-api-config.json
env:
SFCC_SLAS_CLIENT_ID: ${{ secrets.SFCC_SLAS_CLIENT_ID }}
SFCC_ORGANIZATION_ID: ${{ vars.SFCC_ORGANIZATION_ID }}
SFCC_SHORT_CODE: ${{ vars.SFCC_SHORT_CODE }}
SFCC_SITE_ID: ${{ vars.SFCC_SITE_ID }}
run: |
jq '.clientId = env.SFCC_SLAS_CLIENT_ID
| .organizationId = env.SFCC_ORGANIZATION_ID
| .shortCode = env.SFCC_SHORT_CODE
| .siteId = env.SFCC_SITE_ID' config/commerce-api-config.example.json > config/commerce-api-config.json
- run: git apply algolia-demo.patch
- run: npm install
- name: Build and push to Managed Runtime
env:
MRT_USER: ${{ vars.MRT_USER }}
MRT_API_KEY: ${{ secrets.MRT_API_KEY }}
run: npm run push
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
node_modules
build
.idea/

node_modules/
build/

algolia-config.json
commerce-api-config.json
commerce-api-config.json
Loading

0 comments on commit 5b6d7ef

Please sign in to comment.