Skip to content

up_ex_doc_version

up_ex_doc_version #37

---
name: up_ex_doc_version
on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight
workflow_dispatch:
jobs:
test:
name: Update ex_doc version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: 24
elixir-version: 1.13
- run: |
CURR=$(curl -s https://hex.pm/api/packages/ex_doc | jq -r '.latest_stable_version')
TITLE="[automation] Update \`ex_doc\` to ${CURR}"
PR=$(curl -s https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls?state=all%26per_page=100 | jq ".[] | select(.title==\"${TITLE}\")")
echo "Searching for pull request with title ${TITLE}..."
if [ -z "${PR}" ]
then
git config user.name "GitHub Actions"
git config user.email "actions@user.noreply.github.com"
echo " ... not found in 100 most recent pull requests!"
git fetch origin
BRANCH="up_ex_doc_to_${CURR}"
if git branch -a | grep "$BRANCH" > /dev/null; then
echo "Branch $BRANCH found! Bailing out..."
exit
fi
git checkout -b "$BRANCH"
mix deps.get
mix compile
mix up_ex_doc_version "${CURR}"
mix deps.unlock ex_doc
mix deps.get
if ! git diff --exit-code 1> /dev/null ; then
echo "There's stuff to push. Creating a pull request..."
git add .
git commit -m "${TITLE}"
git push origin "$BRANCH"
gh pr create --fill \
--title "${TITLE}" \
--body "This is an automated action to update \`ex_doc\` to version ${CURR}"
else
echo "Nothing to push. Is \`ex_doc\` already at version ${CURR}?"
fi
else
echo " ... found! Bailing out..."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}