Skip to content

Commit

Permalink
Merge pull request #16271 from newrelic/daily-release/Feb-22-2024-8_03
Browse files Browse the repository at this point in the history
Daily release/feb 22 2024 8 03
  • Loading branch information
akristen authored Feb 23, 2024
2 parents bd5f342 + 87d26b6 commit ab97cec
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 2 deletions.
126 changes: 126 additions & 0 deletions .github/workflows/build-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: update PR comment after Netlify notification
env:
repo: ${{ github.repository }}
on:
workflow_dispatch:
inputs:
prNumber:
description: PR to update with build status
required: true
type: number
buildStatus:
description: current build status from Netlify
required: true
type: choice
options:
- building
- succeeded
- failed
deployUrl:
description: URL of live branch deploy
required: false
deployLogUrl:
description: URL of logs
required: true
sha:
description: SHA hash of the commit built
required: true

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
# set body of the PR comment
- name: construct message
id: construct-message
run: |
case '${{ inputs.buildStatus }}' in
"building")
comment_body=$(cat <<-END
### <span aria-hidden="true">⏳</span> Deploy Preview building!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ${{ inputs.sha }} |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ inputs.deployLogUrl }} |
---
END
)
;;
"succeeded")
comment_body=$(cat <<-END
### <span aria-hidden="true">✅</span> Deploy Preview ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ${{ inputs.sha }} |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ inputs.deployLogUrl }} |
|<span aria-hidden="true">😎</span> Deploy Preview | [${{ inputs.deployUrl }}](${{ inputs.deployUrl }}) |
---
END
)
;;
"failed")
comment_body=$(cat <<-END
### <span aria-hidden="true">❌</span> Deploy Preview failed!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ${{ inputs.sha }} |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ inputs.deployLogUrl }} |
---
END
)
;;
esac
{
echo 'comment_body<<EOF'
echo "$comment_body"
echo EOF
} >> "$GITHUB_OUTPUT"
- name: update PR check - pending
if: ${{ inputs.buildStatus == 'building' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-f state='pending' \
-f target_url='${{ inputs.deployLogUrl }}' \
-f description='The build has started' \
-f context='netlify/build' \
/repos/${{ env.repo }}/statuses/${{ inputs.sha }}
- name: update PR check - failed
if: ${{ inputs.buildStatus == 'failed' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-f state='failure' \
-f target_url='${{ inputs.deployLogUrl }}' \
-f description='The build has failed' \
-f context='netlify/build' \
/repos/${{ env.repo }}/statuses/${{ inputs.sha }}
- name: update PR check - succeeded
if: ${{ inputs.buildStatus == 'succeeded' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-f state='success' \
-f target_url='${{ inputs.deployLogUrl }}' \
-f description='The build has finished successfully' \
-f context='netlify/build' \
/repos/${{ env.repo }}/statuses/${{ inputs.sha }}
- name: update PR comment with Netlify status
uses: thollander/actions-comment-pull-request@v2
with:
message: ${{ steps.construct-message.outputs.comment_body }}
pr_number: ${{ inputs.prNumber }}
comment_tag: manual-build-comment
40 changes: 40 additions & 0 deletions .github/workflows/manual-deploy-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Netlify build manual deploy comment

on:
issue_comment:
types: [created]

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
# we use `jq` to parse the GH API response
- name: setup jq
uses: dcarbone/install-jq-action@v2

- name: send request to Netlify build hook
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# when a contributor comments 'netlify build',
# but only on pull requests, not issues
if: |
contains(github.event.comment.body, 'netlify build')
&& ${{ github.event.issue.pull_request }}
run: |
gh_api_url=$(echo ${{ github.event.issue.pull_request.url }} | sed 's/https:\/\/api.github.com//')
gh_api_response=$(gh api $gh_api_url)
branch_name=$(echo $gh_api_response | jq -r .head.ref)
sha=$(echo $gh_api_response | jq -r .head.sha)
pr_number=$(echo $gh_api_response | jq -r .number)
curl -X POST \
"https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_BUILD_HOOK_ID }}?trigger_branch=$branch_name"'&trigger_title=Manual+deploy+preview+for+PR+%23'"$pr_number"'+-+'"$sha"
- name: comment for Netlify to update with preview URL
uses: thollander/actions-comment-pull-request@v2
with:
message: |
### <span aria-hidden="true">⏳</span> Netlify Preview Deployment Information
This comment will auto update when your preview build is ready
comment_tag: manual-build-comment
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ freshnessValidatedDate: never

Use infrastructure monitoring's **Host not reporting** [condition](/docs/infrastructure/new-relic-infrastructure/configuration/infrastructure-alerts-add-edit-or-view-host-alert-information) to notify you when we've stopped receiving data from an infrastructure agent. This feature allows you to dynamically alert on groups of hosts, configure the time window from five to 60 minutes, and take full advantage of <InlinePopover type="alerts" /> notifications.

## Features
## Features [#features]

You can define conditions based on the sets of hosts most important to you, and configure thresholds appropriate for each filtered set of hosts. The **Host not reporting** event triggers when data from the infrastructure agent doesn't reach our [collector](/docs/accounts-partnerships/education/getting-started-new-relic/glossary#collector) within the time frame you specify.

Expand Down Expand Up @@ -92,7 +92,7 @@ To define the **Host not reporting** condition criteria:
3. Define the **Critical** threshold for triggering the notification: minimum 5 minutes, maximum 60 minutes.
4. Enable the **Don't trigger alerts for hosts that perform a clean shutdown** option, if you want to prevent false alerts when you have hosts set to shut down via command line. Currently, this feature is supported on all Windows systems and Linux systems using systemd.
<Callout variant='tip'>
Alternatively, you can add the `hostStatus: shutdown` [tag](/docs/new-relic-one/use-new-relic-one/core-concepts/use-tags-help-organize-find-your-data/) to your host along with checking the option mentioned above. This will stop all **Host Not Reporting** incidents from opening for that host, as long as that tag is on it, regardless of the agent version or OS. Removing the tag will allow the system to open **Host Not Reporting** incidents for that host again.
Additionally, you can add the `hostStatus: shutdown` [tag](/docs/new-relic-one/use-new-relic-one/core-concepts/use-tags-help-organize-find-your-data/) to your host along with checking the option mentioned above. This will stop all **Host not reporting** incidents from opening for that host, as long as that tag is on it, regardless of the agent version or OS. Removing the tag will allow the system to open **Host not reporting** incidents for that host again.
</Callout>

Depending on the policy's [incident preferences](/docs/alerts/new-relic-alerts/configuring-alert-policies/specify-when-new-relic-creates-incidents), it will define which notification channels to use when the defined **Critical** threshold for the condition passes. To avoid "false positives," the host must stop reporting for the entire time period before an incident is opened.
Expand Down

0 comments on commit ab97cec

Please sign in to comment.