Skip to content

up_ex_doc_version

up_ex_doc_version #431

---
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
strategy:
max-parallel: 1
matrix:
triplet:
- otp: '25'
elixir: '1.14'
rebar3: '3.22'
- otp: '26'
elixir: '1.15'
rebar3: '3.22'
- otp: '27'
elixir: '1.17'
rebar3: '3.23'
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.triplet.otp}}
elixir-version: ${{matrix.triplet.elixir}}
rebar3-version: ${{matrix.triplet.rebar3}}
- 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 "[email protected]"
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
set +e
rebar3 do dialyzer, ct
UP_EX_DOC_VERSION_CONTROL_ISSUE=85
if [ $? -ne 0 ]; then
gh issue reopen "${UP_EX_DOC_VERSION_CONTROL_ISSUE}" || true
gh issue edit "${UP_EX_DOC_VERSION_CONTROL_ISSUE}" -t "[automation] Workflow \`up_ex_doc_version\` failed" -b "Something's wrong with workflow \`up_ex_doc_version\`. Check [this](/${GITHUB_REPOSITORY}/actions/workflows/up_ex_doc_version.yml)."
exit 1
else
set -e
gh issue close "${UP_EX_DOC_VERSION_CONTROL_ISSUE}" || true
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
fi
else
echo " ... found! Bailing out..."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}