From 03ff9fa5b67f2f6cc181724bc405b3d7d411eb97 Mon Sep 17 00:00:00 2001 From: Mateusz Front Date: Tue, 23 Apr 2024 10:27:01 +0200 Subject: [PATCH] fix update packages list action --- .github/workflows/update-packages-list.yml | 13 +++++++++++-- scripts/elixir/update_packages_list.exs | 10 ++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-packages-list.yml b/.github/workflows/update-packages-list.yml index 37ceb52a6..4db16f285 100644 --- a/.github/workflows/update-packages-list.yml +++ b/.github/workflows/update-packages-list.yml @@ -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 'bot@membrane.stream' + 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 '' \ No newline at end of file + 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)" \ No newline at end of file diff --git a/scripts/elixir/update_packages_list.exs b/scripts/elixir/update_packages_list.exs index 4ec418cc0..192175426 100644 --- a/scripts/elixir/update_packages_list.exs +++ b/scripts/elixir/update_packages_list.exs @@ -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 != [])) @@ -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 @@ -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) -> @@ -291,3 +291,5 @@ File.read!(readme_path) packages_md ) |> then(&File.write!(readme_path, &1)) + +IO.puts("Packages updated successfully.")