Skip to content

Commit 42d9c2a

Browse files
author
Abdulhakim Ajetunmobi
authored
Add Messages - SMS - V0.1 (#1)
1 parent ae4262a commit 42d9c2a

38 files changed

+13620
-0
lines changed

.github/workflows/preview.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Preview Tutorial
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
types:
7+
- labeled
8+
- synchronize
9+
10+
jobs:
11+
deploy-preview:
12+
if: contains(github.event.pull_request.labels.*.name, 'Preview')
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Get changed files
20+
id: get-changed-files
21+
uses: tj-actions/changed-files@v45
22+
23+
- name: Get changed folder
24+
id: get-changed-folder
25+
env:
26+
ALL_CHANGED_FILES: ${{ steps.get-changed-files.outputs.all_changed_files }}
27+
run: |
28+
first_file=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | grep "tutorials" | head -n 1)
29+
top_level_dir=$(echo "$first_file" | cut -d'/' -f1,2)
30+
echo "dir=$top_level_dir" >> "$GITHUB_OUTPUT"
31+
32+
- name: Check for config file
33+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
34+
run: |
35+
pwd
36+
if [ ! -f tutorial-config.json ]; then
37+
echo "tutorial-config.json not found. Exiting."
38+
exit 1
39+
fi
40+
41+
- name: Setup node
42+
uses: actions/setup-node@v3
43+
with:
44+
node-version: 22.4
45+
46+
- name: Install dependencies
47+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
48+
run: |
49+
node -v
50+
npm -v
51+
npm install
52+
53+
- name: Run build
54+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
55+
run: |
56+
npm run build
57+
58+
- name: Prep deploy
59+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
60+
run: |
61+
shopt -s extglob
62+
rm -rf !(dist|tutorial-config.json)
63+
mkdir -p ./public
64+
cp -r ./dist/* ./public
65+
rm -rf dist
66+
cp -r $GITHUB_WORKSPACE/scripting/DummyServer/* .
67+
68+
NAME=$(jq -r '.slug' tutorial-config.json)
69+
sed -i "s/<NAME>/$NAME/g" vcr.yml
70+
sed -i "s/<ENV>/preview/g" vcr.yml
71+
72+
cat vcr.yml
73+
74+
- name: Install Cloud Runtime CLI
75+
uses: Vonage/cloud-runtime-cli@main
76+
77+
- name: Deploy
78+
id: deploy
79+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
80+
run: |
81+
vcr deploy --api-key ${{ vars.VONAGE_API_KEY }} --api-secret ${{ secrets.VONAGE_API_SECRET }} --region aws.${{ vars.VCR_REGION }} --graphql-endpoint https://graphql.${{ vars.VCR_REGION }}.runtime.vonage.cloud/v1/graphql 2>&1 | tee deploy-vcr-logs.log
82+
url=$(grep -oP 'https://neru-\S+' deploy-vcr-logs.log)
83+
sanitized_url=$(echo "$url" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g")
84+
echo "url=$sanitized_url" >> "$GITHUB_OUTPUT"
85+
86+
- name: Leave comment on PR
87+
uses: actions/github-script@v7
88+
with:
89+
script: |
90+
await github.rest.issues.createComment({
91+
issue_number: context.issue.number,
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
body: 'Your Tutorial Preview has been deployed: ${{ steps.deploy.outputs.url }}'
95+
});

.github/workflows/workspace.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Create Tutorial Workspace
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
types:
7+
- closed
8+
9+
jobs:
10+
create-workspace:
11+
if: github.event.pull_request.merged == true
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Get changed files
19+
id: get-changed-files
20+
uses: tj-actions/changed-files@v45
21+
22+
- name: Get changed folder
23+
id: get-changed-folder
24+
env:
25+
ALL_CHANGED_FILES: ${{ steps.get-changed-files.outputs.all_changed_files }}
26+
run: |
27+
first_file=$(echo "$ALL_CHANGED_FILES" | tr ' ' '\n' | grep "tutorials" | head -n 1)
28+
top_level_dir=$(echo "$first_file" | cut -d'/' -f1,2)
29+
echo "dir=$top_level_dir" >> "$GITHUB_OUTPUT"
30+
31+
- name: Check for config file
32+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
33+
run: |
34+
pwd
35+
if [ ! -f tutorial-config.json ]; then
36+
echo "tutorial-config.json not found. Exiting."
37+
exit 1
38+
fi
39+
40+
- name: Setup node
41+
uses: actions/setup-node@v3
42+
with:
43+
node-version: 22.4
44+
45+
- name: Install dependencies
46+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
47+
run: |
48+
node -v
49+
npm -v
50+
npm install
51+
52+
- name: Run build
53+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
54+
run: |
55+
pwd
56+
npm run build
57+
58+
- name: Prep deploy
59+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
60+
run: |
61+
mkdir -p server
62+
cd server
63+
mkdir -p ./public
64+
cp -r ../dist/* ./public
65+
rm -rf ../dist
66+
cp -r $GITHUB_WORKSPACE/scripting/DummyServer/* .
67+
68+
NAME=$(jq -r '.slug' ../tutorial-config.json)
69+
VERSION=$(jq -r '.version' ../tutorial-config.json)
70+
VERSION=${VERSION//./-}
71+
sed -i "s/<NAME>/$NAME/g" vcr.yml
72+
sed -i "s/<ENV>/$VERSION/g" vcr.yml
73+
74+
cat vcr.yml
75+
76+
- name: Install Cloud Runtime CLI
77+
uses: Vonage/cloud-runtime-cli@main
78+
79+
- name: Deploy
80+
id: deploy
81+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}/server
82+
run: |
83+
vcr deploy --api-key ${{ vars.VONAGE_API_KEY }} --api-secret ${{ secrets.VONAGE_API_SECRET }} --region aws.${{ vars.VCR_REGION }} --graphql-endpoint https://graphql.${{ vars.VCR_REGION }}.runtime.vonage.cloud/v1/graphql 2>&1 | tee deploy-vcr-logs.log
84+
url=$(grep -oP 'https://neru-\S+' deploy-vcr-logs.log)
85+
sanitized_url=$(echo "$url" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g")
86+
echo "url=$sanitized_url" >> "$GITHUB_OUTPUT"
87+
88+
- name: Create Workspace Folder
89+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
90+
run: |
91+
rm -rf server ws
92+
mkdir -p ws
93+
cd ws
94+
pwd
95+
cp ../tutorial-config.json .
96+
cp -r $GITHUB_WORKSPACE/scripting/DummyWorkspace/. .
97+
cp $GITHUB_WORKSPACE/scripting/createWorkspace.sh .
98+
ls -a
99+
./createWorkspace.sh ${{ steps.deploy.outputs.url }}
100+
101+
- name: Tag the commit
102+
id: tag-commit
103+
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
104+
run: |
105+
git config user.name "GitHub Actions"
106+
git config user.email "actions@github.com"
107+
git add --all
108+
109+
slug=$(jq -r '.slug' tutorial-config.json)
110+
version=$(jq -r '.version' tutorial-config.json)
111+
TAG_NAME="${slug}-v${version}"
112+
113+
git commit -m "Adding workspace for ${TAG_NAME}"
114+
git tag -a $TAG_NAME -m "Tagging commit for version ${TAG_NAME}"
115+
116+
git push
117+
git push origin $TAG_NAME
118+
119+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
120+
121+
- name: Zip Workspace
122+
uses: TheDoctor0/zip-release@0.7.6
123+
with:
124+
type: "zip"
125+
directory: "${{ steps.get-changed-folder.outputs.dir }}/ws"
126+
path: "."
127+
filename: "ws.zip"
128+
exclusions: "tutorial-config.json createWorkspace.sh"
129+
130+
- name: Upload a Build Artifact
131+
id: upload-release-artifact
132+
uses: actions/upload-artifact@v4.0.0
133+
with:
134+
path: "${{ steps.get-changed-folder.outputs.dir }}/ws/ws.zip"
135+
136+
- name: Create release assets
137+
uses: ncipollo/release-action@v1
138+
with:
139+
name: Release ${{ steps.tag-commit.outputs.tag_name }}
140+
artifacts: "${{ steps.get-changed-folder.outputs.dir }}/ws/ws.zip"
141+
body: Download and Upload the ws.zip file to Code Hub now.
142+
tag: ${{ steps.tag-commit.outputs.tag_name }}

.gitignore

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/node
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=node
3+
4+
*.zip
5+
.DS_Store
6+
7+
### Node ###
8+
# Logs
9+
logs
10+
*.log
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
lerna-debug.log*
15+
.pnpm-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
# Snowpack dependency directory (https://snowpack.dev/)
53+
web_modules/
54+
55+
# TypeScript cache
56+
*.tsbuildinfo
57+
58+
# Optional npm cache directory
59+
.npm
60+
61+
# Optional eslint cache
62+
.eslintcache
63+
64+
# Optional stylelint cache
65+
.stylelintcache
66+
67+
# Microbundle cache
68+
.rpt2_cache/
69+
.rts2_cache_cjs/
70+
.rts2_cache_es/
71+
.rts2_cache_umd/
72+
73+
# Optional REPL history
74+
.node_repl_history
75+
76+
# Output of 'npm pack'
77+
*.tgz
78+
79+
# Yarn Integrity file
80+
.yarn-integrity
81+
82+
# dotenv environment variable files
83+
.env
84+
.env.development.local
85+
.env.test.local
86+
.env.production.local
87+
.env.local
88+
89+
# parcel-bundler cache (https://parceljs.org/)
90+
.cache
91+
.parcel-cache
92+
93+
# Next.js build output
94+
.next
95+
out
96+
97+
# Nuxt.js build / generate output
98+
.nuxt
99+
dist
100+
101+
# Gatsby files
102+
.cache/
103+
# Comment in the public line in if your project uses Gatsby and not Next.js
104+
# https://nextjs.org/blog/next-9-1#public-directory-support
105+
# public
106+
107+
# vuepress build output
108+
.vuepress/dist
109+
110+
# vuepress v2.x temp and cache directory
111+
.temp
112+
113+
# Docusaurus cache and generated files
114+
.docusaurus
115+
116+
# Serverless directories
117+
.serverless/
118+
119+
# FuseBox cache
120+
.fusebox/
121+
122+
# DynamoDB Local files
123+
.dynamodb/
124+
125+
# TernJS port file
126+
.tern-port
127+
128+
# Stores VSCode versions used for testing VSCode extensions
129+
.vscode-test
130+
131+
# yarn v2
132+
.yarn/cache
133+
.yarn/unplugged
134+
.yarn/build-state.yml
135+
.yarn/install-state.gz
136+
.pnp.*
137+
138+
### Node Patch ###
139+
# Serverless Webpack directories
140+
.webpack/
141+
142+
# Optional stylelint cache
143+
144+
# SvelteKit build / generate output
145+
.svelte-kit
146+
147+
# End of https://www.toptal.com/developers/gitignore/api/node

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Vonage Interactive Onboarding Tutorials

scripting/DummyServer/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
npm ci

0 commit comments

Comments
 (0)