Skip to content

Commit 503d5f0

Browse files
author
Abdulhakim Ajetunmobi
authored
Use GH Pages (#2)
1 parent f60204c commit 503d5f0

File tree

17 files changed

+36
-890
lines changed

17 files changed

+36
-890
lines changed

.github/workflows/preview.yml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,13 @@ jobs:
5555
run: |
5656
npm run build
5757
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"
58+
- name: Deploy to GitHub Pages
59+
uses: peaceiris/actions-gh-pages@v4
60+
with:
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
publish_dir: "${{ steps.get-changed-folder.outputs.dir }}/dist"
63+
publish_branch: gh_pages
64+
destination_dir: "${{ steps.get-changed-folder.outputs.dir }}/preview"
8565

8666
- name: Leave comment on PR
8767
uses: actions/github-script@v7
@@ -91,5 +71,5 @@ jobs:
9171
issue_number: context.issue.number,
9272
owner: context.repo.owner,
9373
repo: context.repo.repo,
94-
body: 'Your Tutorial Preview has been deployed: ${{ steps.deploy.outputs.url }}'
74+
body: 'Your Tutorial Preview has been deployed: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.get-changed-folder.outputs.dir }}/preview'
9575
});

.github/workflows/workspace.yml

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,47 +56,33 @@ jobs:
5656
npm run build
5757
5858
- name: Prep deploy
59+
id: prep-deploy
5960
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"
61+
run: |
62+
NAME=$(jq -r '.slug' ./tutorial-config.json)
63+
VERSION=$(jq -r '.version' ./tutorial-config.json)
64+
65+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
66+
echo "name=$NAME" >> "$GITHUB_OUTPUT"
67+
68+
- name: Deploy to GitHub Pages
69+
uses: peaceiris/actions-gh-pages@v4
70+
with:
71+
github_token: ${{ secrets.GITHUB_TOKEN }}
72+
publish_dir: "${{ steps.get-changed-folder.outputs.dir }}/dist"
73+
publish_branch: gh_pages
74+
destination_dir: "${{ steps.get-changed-folder.outputs.dir }}/${{ steps.prep-deploy.outputs.version }}"
8775

8876
- name: Create Workspace Folder
8977
working-directory: ${{ steps.get-changed-folder.outputs.dir }}
9078
run: |
91-
rm -rf server ws
9279
mkdir -p ws
9380
cd ws
94-
pwd
9581
cp ../tutorial-config.json .
96-
cp -r $GITHUB_WORKSPACE/scripting/DummyWorkspace/. .
82+
cp -r $GITHUB_WORKSPACE/scripting/TemplateWorkspace/. .
9783
cp $GITHUB_WORKSPACE/scripting/createWorkspace.sh .
9884
ls -a
99-
./createWorkspace.sh ${{ steps.deploy.outputs.url }}
85+
./createWorkspace.sh https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.get-changed-folder.outputs.dir }}/${{ steps.prep-deploy.outputs.version }}
10086
10187
- name: Tag the commit
10288
id: tag-commit
@@ -106,9 +92,7 @@ jobs:
10692
git config user.email "actions@github.com"
10793
git add --all
10894
109-
slug=$(jq -r '.slug' tutorial-config.json)
110-
version=$(jq -r '.version' tutorial-config.json)
111-
TAG_NAME="${slug}-v${version}"
95+
TAG_NAME="${{ steps.prep-deploy.outputs.name }}-v${{ steps.prep-deploy.outputs.version }}"
11296
11397
git commit -m "Adding workspace for ${TAG_NAME}"
11498
git tag -a $TAG_NAME -m "Tagging commit for version ${TAG_NAME}"
@@ -139,4 +123,4 @@ jobs:
139123
name: Release ${{ steps.tag-commit.outputs.tag_name }}
140124
artifacts: "${{ steps.get-changed-folder.outputs.dir }}/ws/ws.zip"
141125
body: Download and Upload the ws.zip file to Code Hub now.
142-
tag: ${{ steps.tag-commit.outputs.tag_name }}
126+
tag: ${{ steps.tag-commit.outputs.tag_name }}

scripting/DummyServer/build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripting/DummyServer/index.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)