Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
xripoll-at-wiris committed Jul 13, 2023
1 parent edc92c1 commit 3e65dfc
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 1 deletion.
59 changes: 58 additions & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,68 @@ jobs:
- name: Clean previous deployment of this branch
run: aws s3 rm s3://wiris-integrations-staging-html/${{ matrix.branch }} --recursive

deploy-staging-common:
name: Deploy the staging environment (common elements)
runs-on: ubuntu-latest
needs:
- prepare
- clean-staging
strategy:
fail-fast: true
matrix:
branch: ${{ fromJson(needs.prepare.outputs.branches) }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }}
aws-region: eu-west-2

- name: Upload the common files
run: |
# Replace token %BRANCH% with branch name in staging/branch
find staging/branch -type f -exec sed -i 's/%BRANCH%/${{ matrix.branch }}/g' {} \;
aws s3 cp staging/branch s3://wiris-integrations-staging-html/${{ matrix.branch }} --recursive
aws s3 cp staging/root s3://wiris-integrations-staging-html/ --recursive
- name: Add branch to the list of branches
run: |
BRANCHES=branches
# Check if the remote list of branches exists
aws s3api head-object --bucket wiris-integrations-staging-html --key branches || NOT_EXIST=true
if [ $NOT_EXIST ]; then
# Create empty list of branches
touch "${BRANCHES}"
else
# Copy list of branches from S3 to local
aws s3 cp "s3://wiris-integrations-staging-html/${BRANCHES}" "${BRANCHES}"
fi
# Check if branch name is already in the file
if ! grep -q -F "${{ matrix.branch }}" "${BRANCHES}"; then
# Update local list of branches
echo ${{ matrix.branch }} >> "${BRANCHES}"
# Upload updated file
aws s3 cp "${BRANCHES}" "s3://wiris-integrations-staging-html/${BRANCHES}"
fi
deploy-staging:
name: Deploy the staging environment
runs-on: ubuntu-latest
needs:
- prepare
- clean-staging
- deploy-staging-common
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -95,7 +151,7 @@ jobs:
aws-region: eu-west-2

- name: Build the demos

run: |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}
yarn
Expand Down Expand Up @@ -150,6 +206,7 @@ jobs:
needs:
- prepare
- clean-staging
- deploy-staging-common
- deploy-staging
steps:

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/dismantle-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,18 @@ jobs:
run: |
aws s3 rm s3://wiris-integrations-staging-html/${{ github.event.ref }} --recursive
- name: Remove branch from the list of branches
run: |
BRANCHES=branches
# Copy list of branches from S3 to local
aws s3 cp "s3://wiris-integrations-staging-html/${BRANCHES}" "${BRANCHES}"
# Check if branch name is in the file
if grep -q -F "${{ matrix.branch }}" "${BRANCHES}"; then
# Update local list of branches
sed '/^${{ github.event.ref }}$/d' "${BRANCHES}"
# Upload updated file
aws s3 cp "${BRANCHES}" "s3://wiris-integrations-staging-html/${BRANCHES}"
fi
- name: Invalidate CloudFront cache
run: aws cloudfront create-invalidation --distribution-id $(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, 'integrations.wiris.kitchen')].Id | [0]" --output text) --paths '/*'
23 changes: 23 additions & 0 deletions staging/branch/angular/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>Demos %BRANCH% / Angular</title>
<link rel="stylesheet" href="../../styles.css"/>
</head>
<body>
<a href="..">Demos %BRANCH%</a>
<h1>Demos %BRANCH% / Angular</h1>
<nav>
<section>
<h2>Angular</h2>
<ul>
<li><a href="ckeditor5">CKEditor 5</a></li>
<li><a href="froala">Froala</a></li>
<li><a href="generic">Generic</a></li>
<li><a href="tinymce5">TinyMCE 5</a></li>
</ul>
</section>
</nav>
</body>
</html>
25 changes: 25 additions & 0 deletions staging/branch/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>Demos %BRANCH% / HTML</title>
<link rel="stylesheet" href="../../styles.css"/>
</head>
<body>
<a href="..">Demos %BRANCH%</a>
<h1>Demos %BRANCH% / HTML</h1>
<nav>
<section>
<h2>HTML</h2>
<ul>
<li><a href="ckeditor4">CKEditor 4</a></li>
<li><a href="ckeditor5">CKEditor 5</a></li>
<li><a href="froala">Froala</a></li>
<li><a href="generic">Generic</a></li>
<li><a href="tinymce5">TinyMCE 5</a></li>
<li><a href="tinymce6">TinyMCE 6</a></li>
</ul>
</section>
</nav>
</body>
</html>
43 changes: 43 additions & 0 deletions staging/branch/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>Demos %BRANCH%</title>
<link rel="stylesheet" href="../styles.css"/>
</head>
<body>
<a href="..">All demos</a>
<h1>Demos %BRANCH%</h1>
<nav>
<section>
<h2><a href="html">HTML</a></h2>
<ul>
<li><a href="html/ckeditor4">CKEditor 4</a></li>
<li><a href="html/ckeditor5">CKEditor 5</a></li>
<li><a href="html/froala">Froala</a></li>
<li><a href="html/generic">Generic</a></li>
<li><a href="html/tinymce5">TinyMCE 5</a></li>
<li><a href="html/tinymce6">TinyMCE 6</a></li>
</ul>
</section>
<section>
<h2><a href="angular">Angular</a></h2>
<ul>
<li><a href="angular/ckeditor5">CKEditor 5</a></li>
<li><a href="angular/froala">Froala</a></li>
<li><a href="angular/generic">Generic</a></li>
<li><a href="angular/tinymce5">TinyMCE 5</a></li>
</ul>
</section>
<section>
<h2><a href="react">React</a></h2>
<ul>
<li><a href="react/ckeditor5">CKEditor 5</a></li>
<li><a href="react/froala">Froala</a></li>
<li><a href="react/generic">Generic</a></li>
<li><a href="react/tinymce5">TinyMCE 5</a></li>
</ul>
</section>
</nav>
</body>
</html>
23 changes: 23 additions & 0 deletions staging/branch/react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>Demos %BRANCH% / React</title>
<link rel="stylesheet" href="../../styles.css"/>
</head>
<body>
<a href="..">Demos %BRANCH%</a>
<h1>Demos %BRANCH% / React</h1>
<nav>
<section>
<h2>React</h2>
<ul>
<li><a href="ckeditor5">CKEditor 5</a></li>
<li><a href="froala">Froala</a></li>
<li><a href="generic">Generic</a></li>
<li><a href="tinymce5">TinyMCE 5</a></li>
</ul>
</section>
</nav>
</body>
</html>
29 changes: 29 additions & 0 deletions staging/root/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset="utf-8">
<title>All demos</title>
<link rel="stylesheet" href="styles.css"/>
<script type="module">
// Scan the branches file and generate links to each of them
const response = await fetch('branches');
const branchesString = await response.text();
const branches = branchesString.split(/\r?\n|\r|\n/g);
branches.sort();
for (const branch of branches) {
const element = document.createElement('li');
element.innerHTML = `<a href="${branch}">${branch}</a>`;
document.getElementById('list').appendChild(element);
}
</script>
</head>
<body>
<h1>All demos</h1>
<nav>
<section>
<h2><a href="html">HTML</a></h2>
<ul id="list"></ul>
</section>
</nav>
</body>
</html>
15 changes: 15 additions & 0 deletions staging/root/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
body {
font-family: sans-serif;
}

h2 {
margin: 5px;
}

section {
background-color: #7eff83;;
border: 1px solid #7eff83;;
border-radius: 15px;
padding: 10px;
margin: 5px;
}

0 comments on commit 3e65dfc

Please sign in to comment.