-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
53 lines (46 loc) · 1.52 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: 'Get Description From README Action'
description: 'GitHub Action to get description from README.'
author: 'rtvu'
branding:
icon: 'info'
color: 'gray-dark'
inputs:
readme:
description: 'Path to README'
default: 'README.md'
outputs:
description:
description: 'README''s description'
value: ${{ steps.get-description.outputs.description }}
runs:
using: 'composite'
steps:
-
name: 'Get description'
id: get-description
shell: python3 -u {0} ${{ inputs.readme }}
run: |
import argparse
import os
import sys
def get_description(readme_path):
try:
description = ''
with open(readme_path, 'r') as readme:
for line in readme:
line = line.strip()
if len(line) > 0 and line[0] != '#':
description = line
break
output_path = os.getenv('GITHUB_OUTPUT')
with open(output_path, 'a') as output:
output.write(f'description={description}')
except Exception as exception:
sys.exit(exception)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('readme_path', nargs='?', type=str, help='Path to README', default='README.md')
args = parser.parse_args()
get_description(readme_path=args.readme_path)
if __name__ == '__main__':
main()