-
Notifications
You must be signed in to change notification settings - Fork 15
64 lines (54 loc) · 2.11 KB
/
up_ex_doc_version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
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 "[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
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 }}