Skip to content

Quix-73484: Add descriptor v2.0 (YAML 2.0) documentation page #1656

Quix-73484: Add descriptor v2.0 (YAML 2.0) documentation page

Quix-73484: Add descriptor v2.0 (YAML 2.0) documentation page #1656

name: Test or Dev build
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
#env:
#SITE_DIR: ${{ github.ref }}
#SITE_DIR: subsite
on:
workflow_dispatch:
# We have another workflow for pushing directly to dev
push:
branches:
- 'dev'
tags:
- test-*
pull_request:
types: [opened, reopened, synchronize, ready_for_review, edited]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-html:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Set deployment directory
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
raw_dir="pr${{ github.event.pull_request.number }}"
elif [ "${{ github.ref_type }}" = "tag" ]; then
raw_dir="tag-${{ github.ref_name }}"
elif [ "${{ github.ref_type }}" = "branch" ]; then
raw_dir="branch-${{ github.ref_name }}"
else
raw_dir="run-${{ github.run_id }}"
fi
Deployment_Dir=$(printf '%s' "$raw_dir" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's/[^a-z0-9-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g' \
| cut -c1-63 \
| sed -E 's/^-+//; s/-+$//')
if [ -z "$Deployment_Dir" ]; then
Deployment_Dir="run-${{ github.run_id }}"
fi
echo "Deployment_Dir=$Deployment_Dir" >> "$GITHUB_ENV"
echo "Deployment_Dir=$Deployment_Dir"
- name: blob
run: echo $Deployment_Dir
- name: Checkout docs
uses: actions/checkout@v4
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: python -m pip install --upgrade pip setuptools wheel
# Needed when using more than one repo
# add 'monorepo' to mkdocs.yml file under plugins
- run: pip install mkdocs-monorepo-plugin
- run: pip install mkdocs-exclude-search
# Adds requirements for social plugin. Needed to automatically fill out meta data.
# add 'social' to mkdocs.yml file under plugins
- run: pip install cffi pillow cairosvg
# Material extension now part of mkdocs
- run: pip install mkdocs-material-extensions
# add mkdocs-redirects
# zoom images
- name: Install mkdocs-redirects
run: pip install mkdocs-redirects
# add lightbox
# zoom images
- name: Install MkDocs Light Box
run: pip install mkdocs-glightbox
# add multirepo to support pulling docs from other repos
- name: Install multirepo
run: pip install mkdocs-multirepo-plugin
# add include support for markdown
- name: Install include-markdown
run: pip install mkdocs-include-markdown-plugin
- run: pip install mkdocs
- run: pip install mkdocs-material
# enable when there is an Client Library dev branch
# - name: Extract branch name
# shell: bash
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# id: extract_branch
###### checkout client library files - latest version
- name: Checkout Client Library
uses: actions/checkout@v3
with:
repository: 'quixio/quix-streams'
ref: 'main' # when a dev branch exists we can get the dev content
#ref: '{{ steps.extract_branch.outputs.branch }}'
path: 'quix-streams'
###
# for debugging..
# crawl the files, print the contents of specific files
- name: Crawl and print file hierarchy
run: |
print_files() {
local indent="$1"
shift
# specify the filenames you want to print
local filenames=("index.html" "index.md" "mkdocs.yml")
for path; do
local filename=$(basename "$path")
# check if filename is in filenames
if [[ " ${filenames[@]} " =~ " ${filename} " ]]; then
echo "$filename found at $path. Contents:"
cat "$path"
fi
if [ -d "$path" ]; then
print_files " $indent" "$path"/*
fi
done
}
print_files "" *
- name: Output Importer Logs
run: |
for i in ${{ steps.readme_importer.outputs.logs }}; do
echo $i
done
- name: Build MkDocs Site
run: mkdocs build --no-directory-urls
env:
AccessToken: ${{ secrets.QUIX_STREAMS_ACCESS_TOKEN }}
- name: Create container in Azure blob storage
uses: azure/CLI@v1
env:
QUIXDOCSDEV_BLOB_SAS: ${{ secrets.QUIXDOCSDEV_BLOB_SAS }}
with:
inlineScript: |
sas_token="$QUIXDOCSDEV_BLOB_SAS"
sas_token="${sas_token#?}"
echo "::add-mask::$sas_token"
az storage container create \
--name "${{ env.Deployment_Dir }}" \
--public-access container \
--account-name quixdocsdev \
--sas-token "$sas_token"
- name: Install AzCopy
run: |
curl -fsSL https://aka.ms/downloadazcopy-v10-linux | tar -xz --strip-components=1
sudo mv azcopy /usr/local/bin/
azcopy --version
- name: Upload to blob storage
env:
AZCOPY_CONCURRENCY_VALUE: 64
QUIXDOCSDEV_BLOB_SAS: ${{ secrets.QUIXDOCSDEV_BLOB_SAS }}
run: |
sas_token="$QUIXDOCSDEV_BLOB_SAS"
sas_token="${sas_token#?}"
sas_query="?$sas_token"
echo "::add-mask::$sas_token"
echo "::add-mask::$sas_query"
azcopy copy \
"site/*" \
"https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}$sas_query" \
--recursive=true \
--overwrite=true
# - name: Upload ALL to blob storage
# uses: azure/CLI@v1
# with:
# inlineScript: |
# az login --service-principal -u 172103f9-7886-4f00-a49e-621461d234e1 -p ${{ secrets.DOCSBOT_SECRET }} --tenant 07dc27cd-da6f-4de6-b83d-c4eed0a10602
# az storage blob upload-batch --overwrite true --account-name quixdocsdev --auth-mode key -d '${{ env.Deployment_Dir }}/all_files' -s .
- name: Echo Site URL
run: echo "Docs preview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html"
- name: Comment Site URL
uses: mshick/add-pr-comment@v2
if: always()
with:
message: |
Docs preview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html
message-failure: |
Build failed. URL was not updated.
- name: Send Slack notification
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
# For posting a rich message using Block Kit
payload: |
{
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: A build just left the launch pad\nPreview site available at https://quixdocsdev.blob.core.windows.net/${{ env.Deployment_Dir }}/index.html"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK