Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Build website

on:
workflow_call:
inputs:
node_version:
description: Define the version of Node.JS to use.
required: false
type: string
default: '24'
environment_name:
type: string
required: true
docusaurus_base_url:
required: true
type: string
docusaurus_no_index:
required: true
type: number
default: 0
docusaurus_pr_number:
required: false
type: number
docusaurus_pr_url:
required: false
type: string
artifact_path:
description: Define the artifact path.
required: false
type: string
default: './build/'
artifact_name:
description: Define the artifact name.
required: false
type: string
default: 'dist.zip'
artifact_retention_day:
description: Define retention period in days.
required: false
type: number
default: 1
outputs:
artifact_name:
description: 'Return the name of the built artifact.'
value: ${{ inputs.artifact_name }}

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

# Permissions needed to interact with GitHub's OIDC Token endpoint
permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment_name }}
# Use environment's secrets without creating a deployment object.
# https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/control-deployments#using-environments-without-deployments
deployment: false
steps:
- name: Checkout 🛎️
uses: actions/checkout@v7
with:
fetch-depth: 1
submodules: true

- name: Setup Node.JS 🔧
uses: actions/setup-node@v7
with:
node-version: ${{ inputs.node_version }}
cache: 'npm'
cache-dependency-path: ./package-lock.json

- name: Print NPM version 🌎
shell: bash
run: |
npm --version

- name: Install dependencies 🔧
shell: bash
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
npm ci

- name: Build 🔧
run: |
npm run build
env:
THEOPLAYER_LICENSE: ${{ vars.THEOPLAYER_LICENSE }}
DOCUSAURUS_BASE_URL: ${{ inputs.docusaurus_base_url }}
DOCUSAURUS_NO_INDEX: ${{ inputs.docusaurus_no_index }}
DOCUSAURUS_PR_NUMBER: ${{ inputs.docusaurus_pr_number }}
DOCUSAURUS_PR_URL: ${{ inputs.docusaurus_pr_url }}

- name: Upload Build ☁️
uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact_name }}
path: ${{ inputs.artifact_path }}
retention-days: ${{ inputs.artifact_retention_day }}
67 changes: 67 additions & 0 deletions .github/workflows/_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy website

on:
workflow_call:
inputs:
environment_name:
type: string
required: true
environment_url:
description: |
The URL where the website will be deployed.
This will be shown on the deployment page and on the triggering pull request.
type: string
required: false
default: ''
artifact_name:
description: Name of the built artifact for deployment.
required: true
type: string
s3_prefix:
description: AWS S3 prefix where to store the build.
required: true
type: string

concurrency: deploy-${{ github.ref }}

jobs:
deploy-to-cloudfront:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment_name }}
deployment: true
url: ${{ inputs.environment_url }}
permissions:
id-token: write
steps:
- name: Download build artifact 🗃️
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact_name }}
path: ${{ github.workspace }}/${{ inputs.artifact_name }}

- name: Configure AWS credentials ☁️
uses: aws-actions/configure-aws-credentials@v6
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE }}

- name: 'Sync to ${{ inputs.s3_prefix }} on S3 💾'
run: |
echo "Copying artifact: ${ARTIFACT_PATH} to S3 bucket: ${S3_BUCKET}/${S3_PREFIX}"
aws s3 sync ${ARTIFACT_PATH}/ s3://${S3_BUCKET}/${S3_PREFIX}/ \
--only-show-errors \
--delete
env:
S3_BUCKET: ${{ vars.S3_BUCKET_NAME }}
S3_PREFIX: ${{ inputs.s3_prefix }}
ARTIFACT_PATH: ${{ github.workspace }}/${{ inputs.artifact_name }}

- name: Invalidate Amazon CloudFront 🧹
run: |
aws cloudfront create-invalidation \
--distribution-id ${CF_DISTRIBUTION_ID} \
--paths ${PATH_TO_INVALIDATE}
env:
CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }}
PATH_TO_INVALIDATE: '/${{ inputs.s3_prefix }}*'
47 changes: 47 additions & 0 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint

on:
workflow_call:
inputs:
node_version:
description: Define the version of Node.JS to use.
required: false
type: string
default: '24'

concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true

jobs:
pr-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v7
with:
fetch-depth: 1
submodules: true

- name: Setup Node.JS 🔧
uses: actions/setup-node@v7
with:
node-version: ${{ inputs.node_version }}
cache: 'npm'
cache-dependency-path: ./package-lock.json

- name: Print NPM version 🌎
shell: bash
run: |
npm --version

- name: Install dependencies 🔧
shell: bash
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
npm ci

- run: npm run gen-api-docs
- run: npm run check-format
- run: npm run lint
- run: npm run typecheck
48 changes: 48 additions & 0 deletions .github/workflows/_undeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Undeploy a pull request preview

on:
workflow_call:
inputs:
environment_name:
type: string
required: true
s3_prefix:
description: AWS S3 prefix where the build is located.
required: true
type: string

concurrency: deploy-${{ github.ref }}

jobs:
deploy-to-cloudfront:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment_name }}
deployment: false
permissions:
id-token: write
steps:
- name: Configure AWS credentials ☁️
uses: aws-actions/configure-aws-credentials@v6
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE }}

- name: 'Delete ${{ inputs.s3_prefix }} from S3 💾'
run: |
echo "Delete the files from S3 bucket: ${S3_BUCKET}/${S3_PREFIX}"
aws s3 rm s3://${S3_BUCKET}/${S3_PREFIX} \
--recursive \
--only-show-errors
env:
S3_BUCKET: ${{ vars.S3_BUCKET_NAME }}
S3_PREFIX: ${{ inputs.s3_prefix }}

- name: Invalidate Amazon CloudFront 🧹
run: |
aws cloudfront create-invalidation \
--distribution-id ${CF_DISTRIBUTION_ID} \
--paths '/${S3_PREFIX}/*'
env:
CF_DISTRIBUTION_ID: ${{ vars.CF_DISTRIBUTION_ID }}
S3_PREFIX: ${{ inputs.s3_prefix }}
44 changes: 0 additions & 44 deletions .github/workflows/deploy-staging.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/deploy.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/lint.yml

This file was deleted.

Loading
Loading