Skip to content

AnimalAI - v4.2.0

AnimalAI - v4.2.0 #7

name: Update README with Latest Release
on:
release:
types: [published]
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Fetch the latest release
id: get-latest-release
uses: actions/github-script@v5
with:
script: |
const response = await github.rest.repos.getLatestRelease({
owner: 'Kinds-of-Intelligence-CFI',
repo: 'animal-ai',
});
return response.data.tag_name;
- name: Update README.md file
run: |
LATEST_RELEASE_TAG=${{ steps.get-latest-release.outputs.result }}
LATEST_RELEASE_URL="https://github.com/Kinds-of-Intelligence-CFI/animal-ai/releases/tag/$LATEST_RELEASE_TAG"
MD_FILE_PATH="./README.md"
sed -i "s|\[latest release\].*|\[latest release\]($LATEST_RELEASE_URL)|" $MD_FILE_PATH
# Configure Git
- name: Configure git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# Commit changes
- name: Commit files
run: |
git add $MD_FILE_PATH
git commit -m "Update README.md with the latest release link - $LATEST_RELEASE_TAG" || echo "No changes to commit"
# Push to a new branch
- name: Push changes
run: |
git branch -m update-readme-$LATEST_RELEASE_TAG
git push -u origin HEAD
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
title: "Update README with the latest release link - ${{ steps.get-latest-release.outputs.result }}"
body: "Automatically generated by GitHub Actions."
branch: "update-readme-${{ steps.get-latest-release.outputs.result }}"
delete-branch: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}