File tree 2 files changed +119
-0
lines changed
actions/update-link-index
2 files changed +119
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!--
2
+ this documentation was generated by https://github.com/reakaleek/gh-action-readme
3
+ with the command `VERSION=main gh action-readme update`
4
+ -->
5
+
6
+ # <!-- name--> Update Link Index<!-- /name-->
7
+
8
+ <!-- description-->
9
+ This action updates the link index for the given link reference file.
10
+ <!-- /description-->
11
+
12
+ ## Inputs
13
+
14
+ <!-- inputs-->
15
+ | Name | Description | Required | Default |
16
+ | -----------------------| ----------------------------------------------------------------| ----------| -----------------------------------|
17
+ | ` link_reference_file ` | The path to the link reference file | ` false ` | ` .artifacts/docs/html/links.json ` |
18
+ | ` aws_account_id ` | The AWS account ID to generate the role ARN for | ` false ` | ` 197730964718 ` |
19
+ | ` aws_region ` | The AWS region to use | ` false ` | ` us-east-1 ` |
20
+ | ` aws_s3_bucket_name ` | The name of the S3 bucket to upload the link reference file to | ` false ` | ` elastic-docs-link-index ` |
21
+ <!-- /inputs-->
22
+
23
+ ## Outputs
24
+ <!-- outputs-->
25
+ | Name | Description |
26
+ | ------| -------------|
27
+ <!-- /outputs-->
28
+
29
+ ## Usage
30
+
31
+ <!-- usage action="elastic/docs-builder/actions/update-link-index" version="env:VERSION"-->
32
+ ``` yaml
33
+ name : CI
34
+
35
+ on :
36
+ push :
37
+ branches :
38
+ - main
39
+ tags :
40
+ - " *.*.*"
41
+
42
+ permissions :
43
+ contents : read
44
+ packages : write
45
+
46
+ jobs :
47
+ deploy :
48
+ runs-on : ubuntu-latest
49
+ permissions :
50
+ pages : write
51
+ id-token : write
52
+ environment :
53
+ name : github-pages
54
+ url : ${{steps.deployment.outputs.page_url}}
55
+ steps :
56
+ - name : Publish Github
57
+ uses : elastic/docs-builder/actions/publish@main
58
+ id : deployment
59
+
60
+ - name : Update Link Index
61
+ uses : elastic/docs-builder/actions/update-link-index@main
62
+ ` ` `
63
+ <!--/usage-->
Original file line number Diff line number Diff line change
1
+ name : Update Link Index
2
+
3
+ description : |
4
+ This action updates the link index for the given link reference file.
5
+
6
+ inputs :
7
+ link_reference_file :
8
+ description : ' The path to the link reference file'
9
+ required : false
10
+ default : ' .artifacts/docs/html/links.json'
11
+ aws_account_id :
12
+ description : ' The AWS account ID to generate the role ARN for'
13
+ required : false
14
+ default : ' 197730964718' # elastic-web
15
+ aws_region :
16
+ description : ' The AWS region to use'
17
+ required : false
18
+ default : ' us-east-1'
19
+ aws_s3_bucket_name :
20
+ description : ' The name of the S3 bucket to upload the link reference file to'
21
+ required : false
22
+ default : ' elastic-docs-link-index'
23
+
24
+ runs :
25
+ using : composite
26
+ steps :
27
+ - name : Update Link Index
28
+ run : |
29
+ echo "Updating link index"
30
+ - name : Generate AWS Role ARN
31
+ id : role_arn
32
+ shell : python
33
+ env :
34
+ AWS_ACCOUNT_ID : ${{ inputs.aws_account_id }}
35
+ run : |
36
+ import hashlib
37
+ import os
38
+
39
+ prefix = "elastic-docs-link-index-uploader-"
40
+ aws_account_id = os.environ["AWS_ACCOUNT_ID"]
41
+
42
+ m = hashlib.sha256()
43
+ m.update(os.environ["GITHUB_REPOSITORY"].encode('utf-8'))
44
+ hash = m.hexdigest()[:64-len(prefix)]
45
+ with open(os.environ["GITHUB_OUTPUT"], "a") as f:
46
+ f.write(f"result=arn:aws:iam::{aws_account_id}:role/{prefix}{hash}")
47
+ - name : Configure AWS Credentials
48
+ uses : aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
49
+ with :
50
+ role-to-assume : ${{ steps.role_arn.outputs.result }}
51
+ aws-region : us-east-1
52
+ - name : Upload Link Reference File to S3
53
+ bash : shell
54
+ run : |
55
+ repository_name=$(basename "${GITHUB_REPOSITORY}")
56
+ aws s3 cp ${{ inputs.link_reference_file }} "s3://${{ inputs.aws_s3_bucket_name }}/${repository_name}.json"
You can’t perform that action at this time.
0 commit comments