-
Notifications
You must be signed in to change notification settings - Fork 1
33 lines (27 loc) · 1.11 KB
/
update_readme.yml
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
name: Update README with best runs
on:
push:
branches:
- test
jobs:
update_readme:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract content from best_runs.md
run: |
sed -n '/<!--START_SECTION:best_runs-->/, /<!--END_SECTION:best_runs-->/p' results/best_runs.md > extracted_content.md
- name: Read README.md
id: readme_content
run: |
echo "::set-output name=content::$(cat README.md)"
- name: Update README
run: |
# Extract existing content between markers
existing_content=$(echo "${{ steps.readme_content.outputs.content }}" | sed -n '/<!--START_SECTION:best_runs-->/, /<!--END_SECTION:best_runs-->/p')
# Replace existing content with extracted content from best_runs.md
new_content=$(cat extracted_content.md)
updated_content=$(echo "${{ steps.readme_content.outputs.content }}" | sed "s@${existing_content}@${new_content}@")
# Write updated content back to README.md
echo "${updated_content}" > README.md