Skip to content

Commit

Permalink
fix update packages list action
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek committed Apr 23, 2024
1 parent fb10564 commit 03ff9fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/update-packages-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ jobs:
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
elixir scripts/elixir/update_packages_list.exs
echo "Run script"
elixir scripts/elixir/update_packages_list.exs > output.txt 2> output.txt || ERROR=$? || true
echo "Set status"
STATUS=$(if [ -n "$ERROR" ]; then echo "[Failed]"; else echo "[Passed]"; fi)
echo "Status: ${STATUS}"
echo "Configure git"
git config user.name 'Membrane Bot'
git config user.email '[email protected]'
echo "Checkout"
git checkout -B auto-update-packages-list
echo "Commit"
git add README.md
git commit -m "auto update packages list in readme" --allow-empty
echo "Push"
git push -f -u origin auto-update-packages-list
gh pr create -B master -H auto-update-packages-list --title 'Auto update packages list' --body ''
echo "Create PR"
gh pr create -B master -H auto-update-packages-list --label no-changelog --title "${STATUS} Auto update packages list" --body "$(cat output.txt)"
10 changes: 6 additions & 4 deletions scripts/elixir/update_packages_list.exs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ repos =
|> Stream.map(fn page ->
Process.sleep(gh_req_timeout)
url = "https://api.github.com/orgs/#{org}/repos?per_page=100&page=#{page}"
IO.puts("Fetching #{url}")
Logger.debug("Fetching #{url}")
Req.get!(url, decode_json: [keys: :atoms]).body
end)
|> Enum.take_while(&(&1 != []))
Expand Down Expand Up @@ -185,10 +185,10 @@ lacking_repos =
end)

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

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

Map.has_key?(repos, name) ->
Expand Down Expand Up @@ -291,3 +291,5 @@ File.read!(readme_path)
packages_md
)
|> then(&File.write!(readme_path, &1))

IO.puts("Packages updated successfully.")

0 comments on commit 03ff9fa

Please sign in to comment.