Skip to content

Commit 03ff9fa

Browse files
committed
fix update packages list action
1 parent fb10564 commit 03ff9fa

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/update-packages-list.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ jobs:
1818
env:
1919
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
2020
run: |
21-
elixir scripts/elixir/update_packages_list.exs
21+
echo "Run script"
22+
elixir scripts/elixir/update_packages_list.exs > output.txt 2> output.txt || ERROR=$? || true
23+
echo "Set status"
24+
STATUS=$(if [ -n "$ERROR" ]; then echo "[Failed]"; else echo "[Passed]"; fi)
25+
echo "Status: ${STATUS}"
26+
echo "Configure git"
2227
git config user.name 'Membrane Bot'
2328
git config user.email 'bot@membrane.stream'
29+
echo "Checkout"
2430
git checkout -B auto-update-packages-list
31+
echo "Commit"
2532
git add README.md
2633
git commit -m "auto update packages list in readme" --allow-empty
34+
echo "Push"
2735
git push -f -u origin auto-update-packages-list
28-
gh pr create -B master -H auto-update-packages-list --title 'Auto update packages list' --body ''
36+
echo "Create PR"
37+
gh pr create -B master -H auto-update-packages-list --label no-changelog --title "${STATUS} Auto update packages list" --body "$(cat output.txt)"

scripts/elixir/update_packages_list.exs

+6-4
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ repos =
148148
|> Stream.map(fn page ->
149149
Process.sleep(gh_req_timeout)
150150
url = "https://api.github.com/orgs/#{org}/repos?per_page=100&page=#{page}"
151-
IO.puts("Fetching #{url}")
151+
Logger.debug("Fetching #{url}")
152152
Req.get!(url, decode_json: [keys: :atoms]).body
153153
end)
154154
|> Enum.take_while(&(&1 != []))
@@ -185,10 +185,10 @@ lacking_repos =
185185
end)
186186

187187
unless Enum.empty?(lacking_repos) do
188-
Logger.warning("""
188+
raise """
189189
The following repositories aren't mentioned in the package list:
190190
#{Enum.map_join(lacking_repos, ",\n", & &1.name)}
191-
""")
191+
"""
192192
end
193193

194194
# equip packages with the data from GH and Hex
@@ -203,7 +203,7 @@ packages =
203203
owner != nil ->
204204
Process.sleep(gh_req_timeout)
205205
url = "https://api.github.com/repos/#{owner}/#{name}"
206-
IO.puts("Fetching #{url}")
206+
Logger.debug("Fetching #{url}")
207207
Req.get!(url, decode_json: [keys: :atoms]).body
208208

209209
Map.has_key?(repos, name) ->
@@ -291,3 +291,5 @@ File.read!(readme_path)
291291
packages_md
292292
)
293293
|> then(&File.write!(readme_path, &1))
294+
295+
IO.puts("Packages updated successfully.")

0 commit comments

Comments
 (0)