Update best runs in README.md #21
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 Best Runs | |
on: | |
push: | |
branches: | |
- test # Change this to your main branch name if different | |
jobs: | |
update_best_runs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Read Best Runs Content | |
id: read_best_runs | |
run: | | |
# Read the content of best_runs.md file | |
content=$(cat results/best_runs.md) | |
#print the content | |
echo "$content" | |
- name: Update README.md | |
run: | | |
# Read the content of README.md | |
readme_content=$(cat README.md) | |
# Replace content between <!--START_SECTION:best_runs--> and <!--END_SECTION:best_runs--> | |
new_content="<!--START_SECTION:best_runs-->\n${{ steps.read_best_runs.outputs.content }}\n<!--END_SECTION:best_runs-->" | |
updated_readme_content=$(echo "$readme_content" | sed -e '/<!--START_SECTION:best_runs-->/, /<!--END_SECTION:best_runs-->/c\'"$new_content") | |
# Update README.md | |
echo "$updated_readme_content" > README.md | |
# make commit if changes are there | |
if [ "$readme_content" != "$updated_readme_content" ]; then | |
echo "Committing the changes..." | |
git config --global user.name "Md Mijanur Rahman" | |
git config --global user.email " | |
git add README.md | |
git commit -m "Update best runs in README.md" | |
git push | |
else | |
echo "No changes in README.md. So, No commit" | |
fi |