-
Notifications
You must be signed in to change notification settings - Fork 15
89 lines (79 loc) · 3.14 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
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 }}