Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 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,66 @@ | ||
name: Deploy Demo | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
AURO_SURGE_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Deploying Demo to Main | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Build Demo | ||
run: | | ||
npm ci | ||
npm run build | ||
- name: Update HTML Scripts | ||
run: | | ||
curl https://raw.githubusercontent.com/AlaskaAirlines/auro-library/main/scripts/config/useBundles.js -o useBundles.js | ||
node useBundles.js | ||
- name: Create Surge Domain | ||
run: | | ||
repo_name=$(echo ${{github.repository}} | tr / -) | ||
branch_domain_name=$(echo ${{github.head_ref}} | tr / -) | ||
echo "domain_name=$repo_name-$branch_domain_name.surge.sh" >> $GITHUB_ENV | ||
- name: Deploy to Surge | ||
run: | | ||
npm install -g surge@0.23; | ||
surge ./ ${{env.domain_name}} --token ${{secrets.AURO_SURGE_TOKEN}} | tee surge_output.txt | ||
deployment_output=$(cat surge_output.txt | grep -e "Success\|Error\|Aborted" | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g') | ||
success_message="Success" | ||
! [[ $deployment_output =~ $success_message ]] && exit 1 | ||
echo "deployment_output=$deployment_output" >> $GITHUB_ENV | ||
- name: Format Deployment Message | ||
run: | | ||
npm install -g urls-md@5; | ||
deployment_message=$(echo "${{env.deployment_output}}/demo/" | urls-md) | ||
echo "deployment_result=$deployment_message" >> $GITHUB_ENV | ||
- name: Comment Success to PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
message: | | ||
Surge demo deployment succeeded! 🚀🚀🚀 | ||
${{env.deployment_result}} | ||
comment_tag: demo_comment | ||
|
||
- name: Comment Failure to PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
if: ${{failure()}} | ||
with: | ||
message: | | ||
Surge demo deployment failed! 😭 | ||
comment_tag: demo_comment | ||
|