Skip to content

Add preview workflow #10

Add preview workflow

Add preview workflow #10

Workflow file for this run

name: preview
on:
pull_request: ~
permissions:
contents: read
packages: read
id-token: write
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Bootstrap Action Workspace
id: bootstrap
uses: ./.github/actions/bootstrap
- name: Publish AOT
run: ./build.sh publishbinaries
# we run our artifact directly please use the prebuild
# elastic/docs-builder@main GitHub Action for all other repositories!
- name: Build documentation
run: .artifacts/publish/docs-builder/release/docs-builder --strict --path-prefix "/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}"
- name: Generate ARNs
id: generate_arns
shell: python
env:
AWS_ACCOUNT_ID: 197730964718
run: |
import hashlib
import os
prefix = "elastic-docs-v3-preview-"
aws_account_id = os.environ["AWS_ACCOUNT_ID"]
m = hashlib.sha256()
m.update(os.environ["GITHUB_REPOSITORY"].encode('utf-8'))
hash = m.hexdigest()[:64-len(prefix)]
name = f"{prefix}{hash}"
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"role_arn=arn:aws:iam::{aws_account_id}:role/{name}", file=f)
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ steps.generate_arns.outputs.role_arn }}
aws-region: us-east-1
- name: Upload to S3
run: |
aws s3 sync .artifacts/docs/html "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}" --delete
aws cloudfront create-invalidation --distribution-id EKT7LT5PM8RKS --paths "/${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}/*"