Open listiani13 opened 1 year ago
Agreed, this feature will help clean up pull requests which go though multiple changes.
Thanks for the feedback to you both! This feature is currently intended, as any changes to the PR are intended to be within the PR thread so that new comments are made aware of the changes. If this ask gets traction, we may investigate considering this change.
Is there a way to disable these comments entirely? We are using multiple Static Web Apps for a single repo so it gets a little messy with multiple comments for every deployed commit.
Please provide an option to avoid spamming our PRs with these comments.
We have pull requests with 8 normal comments and over 30 comments with the same preview URL over and over. Since we deploy two version of our app for each PR it becomes twice as bad as "normal". Becomes very hard to follow the actual conversation when we keep getting the same preview URLs spammed over and over, for every change pushed to the branch. I tried to make a Github action that would clean up duplicate comments, but unforunately this also leaves a "comment was deleted" line in the history, so didn't quite do as much as I hoped.
In the meantime, I used this before the deploy step...
- run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments `
| ConvertFrom-Json `
| Where-Object body -like 'Azure Static Web Apps: Your stage site is ready! Visit it here: *' `
| ForEach-Object {
gh api repos/${{ github.repository }}/issues/comments/$($_.id) -X DELETE
}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Microsoft - please make improvements to this 🙏 - for inspiration pls take a look at how great Netlify's UX is:
(Thanks for that tip @smokedlinq - I just needed to add continue-on-error: true
to that step as it wasn't working after merging so it didn't get deployed. works well now!)
I have used the new permission requirement for workflows to kind workaround this. If you don't grant the deployment job the write permissions for pull requests, it seems to be able to do everything it should, except post the comment. Since all PR URLs are predictable based on the PR number, you can use the following action, which adds a "sticky" comment (never adds more than one, and updates that one) to add a second job that is dependant on the deployment job that actually posts a custom comment with the link in it. "needs" and "permissions" are the key in the sample below.
https://github.com/marketplace/actions/add-pr-comment
I ended up with something along the lines of this:
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
app_location: "/"
api_location: ""
output_location: "dist"
add_staging_comment:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
needs: build_and_deploy_job
runs-on: ubuntu-latest
permissions:
pull-requests: write
name: Add Staging URL to PR comments
steps:
- uses: mshick/add-pr-comment@v2
if: always()
with:
message-id: env-name-url
message: Staging env available at https://xxx-yyy-zzz-${{ github.event.number }}.region.1.azurestaticapps.net
message-failure: Staging environment not updated, because build failed.
Is there a place where one could contribute a PR to the code that runs this workflow? I couldn't find it, but I'd be happy to contribute something that could address this problem if I knew where to do that.
@aberonni: Is there a place where one could contribute a PR to the code that runs this workflow? I couldn't find it, but I'd be happy to contribute something that could address this problem if I knew where to do that.
This is the GitHub Action that runs: https://github.com/Azure/static-web-apps-deploy But it uses a Docker-image that's not open-source... 😿
Is your feature request related to a problem? Please describe. Currently we're using
Azure/static-web-apps-deploy@v1
to deploy preview environment on PR. However, we noticed that each time Azure re-deploying, it will add new comment which kinda clouded the PRDescribe the solution you'd like Could we only make the bot comment once & update the link in there (and it's not like the URL will ever change I assume? Since it's relying on pull request number)
Describe alternatives you've considered Haven't had any alternatives currently