-
Notifications
You must be signed in to change notification settings - Fork 32
Add update-link-index action #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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--> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.