Update README with new content #5
Workflow file for this run
This file contains 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
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: | | |
# Read existing content from README.md | |
existing_content="${{ steps.readme_content.outputs.content }}" | |
# Read new content from extracted_content.md | |
new_content="$(cat extracted_content.md)" | |
# Replace existing content between markers with new content | |
updated_content="${existing_content/<!--START_SECTION:best_runs-->*/<!--START_SECTION:best_runs-->\\${new_content}\\<!--END_SECTION:best_runs-->}" | |
# Write updated content back to README.md | |
echo "${updated_content}" > README.md |