Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
78 changes: 78 additions & 0 deletions actions/update-link-index/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!--
this documentation was generated by https://github.com/reakaleek/gh-action-readme
with the command `VERSION=main gh action-readme update`
-->

# <!--name-->Update Link Index<!--/name-->

<!--description-->
This action updates the link index for the given link reference file.
<!--/description-->

## Inputs

<!--inputs-->
| Name | Description | Required | Default |
|-----------------------|----------------------------------------------------------------|----------|-----------------------------------|
| `link_reference_file` | The path to the link reference file | `false` | `.artifacts/docs/html/links.json` |
| `aws_account_id` | The AWS account ID to generate the role ARN for | `false` | `197730964718` |
| `aws_region` | The AWS region to use | `false` | `us-east-1` |
| `aws_s3_bucket_name` | The name of the S3 bucket to upload the link reference file to | `false` | `elastic-docs-link-index` |
<!--/inputs-->

## Outputs
<!--outputs-->
| Name | Description |
|------|-------------|
<!--/outputs-->

## Usage

<!--usage action="elastic/docs-builder/actions/update-link-index" version="env:VERSION"-->
```yaml
name: CI

on:
push:
branches:
- main
tags:
- "*.*.*"

permissions:
contents: read
packages: write

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
steps:
- id: repo-basename
run: 'echo "value=`basename ${{ github.repository }}`" >> $GITHUB_OUTPUT'
- uses: actions/checkout@v4
- name: Setup Pages
id: pages
uses: actions/[email protected]
- name: Build documentation
uses: elastic/docs-builder@main
with:
prefix: '${{ steps.repo-basename.outputs.value }}'
- name: Upload artifact
uses: actions/[email protected]
with:
path: .artifacts/docs/html

- name: Deploy artifact
id: deployment
uses: actions/[email protected]

- name: Update Link Index
uses: elastic/docs-builder/actions/update-link-index@main
```
<!--/usage-->
56 changes: 56 additions & 0 deletions actions/update-link-index/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Update Link Index

description: |
This action updates the link index for the given link reference file.

inputs:
link_reference_file:
description: 'The path to the link reference file'
required: false
default: '.artifacts/docs/html/links.json'
aws_account_id:
description: 'The AWS account ID to generate the role ARN for'
required: false
default: '197730964718' # elastic-web
aws_region:
description: 'The AWS region to use'
required: false
default: 'us-east-1'
aws_s3_bucket_name:
description: 'The name of the S3 bucket to upload the link reference file to'
required: false
default: 'elastic-docs-link-index'

runs:
using: composite
steps:
- name: Update Link Index
run: |
echo "Updating link index"
- name: Generate AWS Role ARN
id: role_arn
shell: python
env:
AWS_ACCOUNT_ID: ${{ inputs.aws_account_id }}
run: |
import hashlib
import os

prefix = "elastic-docs-link-index-uploader-"
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)]
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"result=arn:aws:iam::{aws_account_id}:role/{prefix}{hash}")
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
role-to-assume: ${{ steps.role_arn.outputs.result }}
aws-region: us-east-1
- name: Upload Link Reference File to S3
bash: shell
run: |
repository_name=$(basename "${GITHUB_REPOSITORY}")
aws s3 cp ${{ inputs.link_reference_file }} "s3://${{ inputs.aws_s3_bucket_name }}/${repository_name}.json"
Loading