mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
Merge pull request #7306 from BlueWallet/eeoe
OPS: Delete previous "APK available" comments
This commit is contained in:
commit
f7e7d67d76
@ -90,7 +90,6 @@ platform :android do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc "Upload APK to BrowserStack and post result as PR comment"
|
desc "Upload APK to BrowserStack and post result as PR comment"
|
||||||
lane :upload_to_browserstack_and_comment do
|
lane :upload_to_browserstack_and_comment do
|
||||||
Dir.chdir(project_root) do
|
Dir.chdir(project_root) do
|
||||||
@ -120,8 +119,10 @@ platform :android do
|
|||||||
browserstack_hashed_id = app_url.gsub('bs://', '')
|
browserstack_hashed_id = app_url.gsub('bs://', '')
|
||||||
pr_number = ENV['GITHUB_PR_NUMBER']
|
pr_number = ENV['GITHUB_PR_NUMBER']
|
||||||
|
|
||||||
|
comment_identifier = '### APK Successfully Uploaded to BrowserStack'
|
||||||
|
|
||||||
comment = <<~COMMENT
|
comment = <<~COMMENT
|
||||||
### APK Successfully Uploaded to BrowserStack
|
#{comment_identifier}
|
||||||
|
|
||||||
You can test it on the following devices:
|
You can test it on the following devices:
|
||||||
|
|
||||||
@ -139,11 +140,39 @@ platform :android do
|
|||||||
**BrowserStack App URL**: #{app_url}
|
**BrowserStack App URL**: #{app_url}
|
||||||
COMMENT
|
COMMENT
|
||||||
|
|
||||||
# Post PR comment if PR number is available
|
# Delete Previous BrowserStack Comments
|
||||||
if pr_number
|
if pr_number
|
||||||
begin
|
begin
|
||||||
sh("GH_TOKEN=#{ENV['GH_TOKEN']} gh pr comment #{pr_number} --body '#{comment}'")
|
repo = ENV['GITHUB_REPOSITORY'] # Format: "owner/repo"
|
||||||
UI.success("Posted comment to PR ##{pr_number}")
|
repo_owner, repo_name = repo.split('/')
|
||||||
|
|
||||||
|
UI.message("Fetching existing comments for PR ##{pr_number}...")
|
||||||
|
|
||||||
|
comments_json = `gh api -X GET /repos/#{repo_owner}/#{repo_name}/issues/#{pr_number}/comments`
|
||||||
|
comments = JSON.parse(comments_json)
|
||||||
|
|
||||||
|
comments.each do |comment|
|
||||||
|
if comment['body'].start_with?(comment_identifier)
|
||||||
|
comment_id = comment['id']
|
||||||
|
UI.message("Deleting previous comment ID: #{comment_id}...")
|
||||||
|
`gh api -X DELETE /repos/#{repo_owner}/#{repo_name}/issues/comments/#{comment_id}`
|
||||||
|
UI.success("Deleted comment ID: #{comment_id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
rescue => e
|
||||||
|
UI.error("Failed to delete previous comments: #{e.message}")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
UI.important("No PR number found. Skipping deletion of previous comments.")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Post New Comment to PR
|
||||||
|
if pr_number
|
||||||
|
begin
|
||||||
|
escaped_comment = comment.gsub("'", "'\\''")
|
||||||
|
sh("GH_TOKEN=#{ENV['GH_TOKEN']} gh pr comment #{pr_number} --body '#{escaped_comment}'")
|
||||||
|
UI.success("Posted new comment to PR ##{pr_number}")
|
||||||
rescue => e
|
rescue => e
|
||||||
UI.error("Failed to post comment to PR: #{e.message}")
|
UI.error("Failed to post comment to PR: #{e.message}")
|
||||||
end
|
end
|
||||||
@ -151,10 +180,9 @@ platform :android do
|
|||||||
UI.important("No PR number found. Skipping PR comment.")
|
UI.important("No PR number found. Skipping PR comment.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# ===========================
|
# ===========================
|
||||||
# iOS Lanes
|
# iOS Lanes
|
||||||
# ===========================
|
# ===========================
|
||||||
@ -412,7 +440,7 @@ lane :build_app_lane do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
# ===========================
|
# ===========================
|
||||||
# Global Lanes
|
# Global Lanes
|
||||||
# ===========================
|
# ===========================
|
||||||
@ -561,5 +589,5 @@ lane :update_release_notes do |options|
|
|||||||
UI.error("No localization found for locale #{locale}")
|
UI.error("No localization found for locale #{locale}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user