Skip to content

Use dotenv_if_exists #2627

Use dotenv_if_exists

Use dotenv_if_exists #2627

name: docs-deploy-preview
# Deploys a preview of the docs website using launchpad.
on:
push:
branches-ignore:
- main
workflow_dispatch:
permissions:
contents: read
pull-requests: read
env:
JETPACK_SECRET_KEY: ${{ secrets.JETPACK_SECRET_KEY }}
jobs:
markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
docs:
- 'docs/**'
- name: markdownlint-cli
uses: nosborn/[email protected]
with:
files: docs/app/docs
config_file: docs/.markdownlint.yaml
docs-deploy-preview:
runs-on: ubuntu-latest
needs: markdown-lint
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
docs:
- 'docs/**'
- uses: bahmutov/npm-install@v1
if: steps.filter.outputs.docs == 'true'
with:
working-directory: docs/app
- name: Mount docs node_modules
if: steps.filter.outputs.docs == 'true'
uses: actions/cache@v3
with:
path: docs/app/node_modules
key: docs-node-modules
- name: Docs build
if: steps.filter.outputs.docs == 'true'
run: |
yarn install
yarn run build
working-directory: docs/app
- name: Deploy docs preview
if: steps.filter.outputs.docs == 'true'
run: |
curl https://get.jetpack.io/launchpad -fsSL | bash -s -- -f
# Make the GitHub branch name safe for Kubernetes namespaces names:
#
# * `sed "s/[^0-9a-z]/-/g"`: replace any invalid or uppercase characters in
# the branch name with dashes.
# * `tr -s -`: squash repeated consecutive dashes into one.
# * `cut -b -39`: truncate the name to 39 characters, leaving 24 for
# "devbox-docs-preview-" and "-ref" for a max of 63.
safe_github_ref="$(echo "${GITHUB_REF_NAME}" | sed "s/[^0-9a-z]/-/g" | cut -b -32)"
namespace="$(echo "jetpack-io-preview-devbox-${safe_github_ref}-ref" | tr -s -)"
launchpad up docs \
--ttl 300 --debug \
-n "$namespace"