|
| 1 | +# Change Tracking Action |
| 2 | + |
| 3 | +This action creates a single New Relic change tracking event for one account/entity combination. Call this action multiple times to create events for multiple accounts or entities. |
| 4 | + |
| 5 | +## Required Secrets |
| 6 | + |
| 7 | +Before using this action, you need to create the following GitHub secrets: |
| 8 | + |
| 9 | +### API Keys |
| 10 | +- `NR_CHANGE_TRACKING_API_KEY_NR1` - New Relic User API key for account 1067061 |
| 11 | +- `NR_CHANGE_TRACKING_API_KEY_BROWSER` - New Relic User API key for account 550352 |
| 12 | + |
| 13 | +### Entity GUIDs |
| 14 | +- `NR_ENTITY_GUID_NR1_STAGING` - Entity GUID for account 1067061 staging environment |
| 15 | +- `NR_ENTITY_GUID_NR1_US_PROD` - Entity GUID for account 1067061 US production |
| 16 | +- `NR_ENTITY_GUID_NR1_EU_PROD` - Entity GUID for account 1067061 EU production |
| 17 | +- `NR_ENTITY_GUID_BROWSER_STAGING` - Entity GUID for account 550352 staging environment |
| 18 | + |
| 19 | +**NOTE: The workflow action must have access to staging to publish successfully in staging region** |
| 20 | + |
| 21 | +## Inputs |
| 22 | + |
| 23 | +| Input | Required | Default | Description | |
| 24 | +|-------|----------|---------|-------------| |
| 25 | +| `accountId` | Yes | - | New Relic account ID (e.g., 1067061, 550352) | |
| 26 | +| `entityGuid` | Yes | - | Entity GUID for the application | |
| 27 | +| `apiKey` | Yes | - | New Relic User API key for the account | |
| 28 | +| `region` | Yes | - | New Relic region (US, EU, dev or Staging) | |
| 29 | +| `version` | Yes | - | Version being deployed | |
| 30 | +| `category` | No | Deployment | Category of event (Deployment or Feature Flag) | |
| 31 | +| `type` | No | Basic | Type of deployment (Basic, Rollback, Blue Green, Canary, Rolling, Shadow) | |
| 32 | +| `featureFlagId` | No | - | ID of the feature flag (required when category is Feature Flag) | |
| 33 | +| `description` | No | - | Description of the event | |
| 34 | +| `changelog` | No | - | Changelog for the deployment (URL or text) | |
| 35 | +| `commit` | No | - | Commit hash for the deployment | |
| 36 | +| `deepLink` | No | - | Deep link URL for the deployment | |
| 37 | +| `user` | No | - | Username of the actor or bot | |
| 38 | +| `groupId` | No | - | String to correlate two or more events | |
| 39 | +| `shortDescription` | No | - | Short description for the event | |
| 40 | + |
| 41 | +## Supported Environments and Regions |
| 42 | + |
| 43 | +| Environment | Region | Account 1067061 Secret | Account 550352 Secret | |
| 44 | +|-------------|--------|------------------------|----------------------| |
| 45 | +| staging | Staging | `NR_ENTITY_GUID_NR1_STAGING` | `NR_ENTITY_GUID_BROWSER_STAGING` | |
| 46 | +| us-prod | US | `NR_ENTITY_GUID_NR1_US_PROD` | N/A | |
| 47 | +| eu-prod | EU | `NR_ENTITY_GUID_NR1_EU_PROD` | N/A | |
| 48 | + |
| 49 | +**Note:** Dev environment is not supported by the New Relic Change Tracking API. |
| 50 | + |
| 51 | +## Usage Examples |
| 52 | + |
| 53 | +### Basic Deployment Event (Single Account) |
| 54 | + |
| 55 | +```yaml |
| 56 | +- name: Create change tracking event (Account 1067061) |
| 57 | + uses: ./.github/actions/change-tracking |
| 58 | + with: |
| 59 | + accountId: '1067061' |
| 60 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_STAGING }} |
| 61 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 62 | + region: 'Staging' |
| 63 | + version: 'staging-latest' |
| 64 | +``` |
| 65 | +
|
| 66 | +### Multiple Accounts for Same Environment |
| 67 | +
|
| 68 | +```yaml |
| 69 | +# Create event for account 1067061 |
| 70 | +- name: Create staging change tracking event (Account 1067061) |
| 71 | + uses: ./.github/actions/change-tracking |
| 72 | + with: |
| 73 | + accountId: '1067061' |
| 74 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_STAGING }} |
| 75 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 76 | + region: 'Staging' |
| 77 | + version: 'staging-latest' |
| 78 | + shortDescription: 'Staging: main branch deployment' |
| 79 | + commit: ${{ github.sha }} |
| 80 | + user: ${{ github.actor }} |
| 81 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 82 | + |
| 83 | +# Create event for account 550352 |
| 84 | +- name: Create staging change tracking event (Account 550352) |
| 85 | + uses: ./.github/actions/change-tracking |
| 86 | + with: |
| 87 | + accountId: '550352' |
| 88 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_BROWSER_STAGING }} |
| 89 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_BROWSER }} |
| 90 | + region: 'Staging' |
| 91 | + version: 'staging-latest' |
| 92 | + shortDescription: 'Staging: main branch deployment' |
| 93 | + commit: ${{ github.sha }} |
| 94 | + user: ${{ github.actor }} |
| 95 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 96 | +``` |
| 97 | +
|
| 98 | +This allows you to see all related deployments grouped together in New Relic. |
| 99 | +
|
| 100 | +### Production Deployment with Rolling Type |
| 101 | +
|
| 102 | +```yaml |
| 103 | +- name: Get version number |
| 104 | + id: agent-loader-version |
| 105 | + run: echo "results=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT |
| 106 | + |
| 107 | +- name: Create US production change tracking event |
| 108 | + uses: ./.github/actions/change-tracking |
| 109 | + with: |
| 110 | + accountId: '1067061' |
| 111 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_US_PROD }} |
| 112 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 113 | + region: 'US' |
| 114 | + version: ${{ steps.agent-loader-version.outputs.results }} |
| 115 | + type: 'Rolling' |
| 116 | + description: 'Production release v${{ steps.agent-loader-version.outputs.results }}' |
| 117 | + shortDescription: 'US Prod: v${{ steps.agent-loader-version.outputs.results }}' |
| 118 | + commit: ${{ github.sha }} |
| 119 | + user: ${{ github.actor }} |
| 120 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 121 | +``` |
| 122 | +
|
| 123 | +### Feature Flag Events |
| 124 | +
|
| 125 | +When feature flags are updated (e.g., changes to `released.js`), create a Feature Flag event: |
| 126 | + |
| 127 | +```yaml |
| 128 | +- name: Check if released.js changed |
| 129 | + id: check-released |
| 130 | + run: | |
| 131 | + if git diff HEAD^ HEAD --name-only | grep -q ".github/actions/build-ab/templates/released.js"; then |
| 132 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 133 | + else |
| 134 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 135 | + fi |
| 136 | +
|
| 137 | +- name: Create dev change tracking event (Account 1067061) |
| 138 | + uses: ./.github/actions/change-tracking |
| 139 | + with: |
| 140 | + accountId: '1067061' |
| 141 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_STAGING }} |
| 142 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 143 | + region: 'Staging' |
| 144 | + version: dev-latest |
| 145 | + category: ${{ steps.check-released.outputs.changed == 'true' && 'Feature Flag' || 'Deployment' }} |
| 146 | + type: 'Basic' |
| 147 | + featureFlagId: ${{ steps.check-released.outputs.changed == 'true' && 'hardcoded feature flag' || '' }} |
| 148 | + description: ${{ steps.check-released.outputs.changed == 'true' && 'Feature flag configuration updated' || 'Standard deployment' }} |
| 149 | + shortDescription: ${{ steps.check-released.outputs.changed == 'true' && 'Dev: Feature flags updated' || 'Dev: Deployment' }} |
| 150 | + commit: ${{ github.sha }} |
| 151 | + user: ${{ github.actor }} |
| 152 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 153 | +``` |
| 154 | + |
| 155 | +### Shadow Deployment (Experiment) |
| 156 | + |
| 157 | +```yaml |
| 158 | +- name: Create experiment change tracking event |
| 159 | + uses: ./.github/actions/change-tracking |
| 160 | + with: |
| 161 | + accountId: '1067061' |
| 162 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_STAGING }} |
| 163 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 164 | + region: 'Staging' |
| 165 | + version: 'dev-experiment-branch-name' |
| 166 | + type: 'Shadow' |
| 167 | + description: 'Experiment deployment for branch experiment-branch-name' |
| 168 | + shortDescription: 'Experiment: experiment-branch-name' |
| 169 | + commit: ${{ github.sha }} |
| 170 | + user: ${{ github.actor }} |
| 171 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 172 | +``` |
| 173 | + |
| 174 | +### Correlating Multiple Events |
| 175 | + |
| 176 | +Use the same `groupId` across multiple action calls to correlate events: |
| 177 | + |
| 178 | +```yaml |
| 179 | +# All these events are correlated via the same groupId |
| 180 | +- name: Create US prod event |
| 181 | + uses: ./.github/actions/change-tracking |
| 182 | + with: |
| 183 | + accountId: '1067061' |
| 184 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_US_PROD }} |
| 185 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 186 | + region: 'US' |
| 187 | + version: '1.2.3' |
| 188 | + shortDescription: 'US Prod: v1.2.3' |
| 189 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 190 | +
|
| 191 | +- name: Create EU prod event |
| 192 | + uses: ./.github/actions/change-tracking |
| 193 | + with: |
| 194 | + accountId: '1067061' |
| 195 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_EU_PROD }} |
| 196 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 197 | + region: 'EU' |
| 198 | + version: '1.2.3' |
| 199 | + shortDescription: 'EU Prod: v1.2.3' |
| 200 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 201 | +
|
| 202 | +- name: Create dev event |
| 203 | + uses: ./.github/actions/change-tracking |
| 204 | + with: |
| 205 | + accountId: '1067061' |
| 206 | + entityGuid: ${{ secrets.NR_ENTITY_GUID_NR1_STAGING }} |
| 207 | + apiKey: ${{ secrets.NR_CHANGE_TRACKING_API_KEY_NR1 }} |
| 208 | + region: 'Staging' |
| 209 | + version: '1.2.3' |
| 210 | + shortDescription: 'Dev: Prod release v1.2.3' |
| 211 | + groupId: '${{ github.run_id }}-${{ github.sha }}' |
| 212 | +``` |
| 213 | + |
| 214 | +## Notes |
| 215 | + |
| 216 | +- The action creates a **single** change tracking event for one account/entity combination |
| 217 | +- Call the action multiple times to create events for multiple accounts or entities |
| 218 | +- The action uses `sudo snap install newrelic-cli` to install the New Relic CLI on Linux runners |
| 219 | +- The action runs on the `Browser-Agent-Assigned-IP-Linux` runner when specified in the workflow |
| 220 | +- **Categories supported**: |
| 221 | + - `Deployment` - For code deployments (default). Required field: `version`. Optional fields: `changelog`, `commit`, `deepLink` |
| 222 | + - `Feature Flag` - For feature flag changes. Required field: `featureFlagId` |
| 223 | +- Event types follow New Relic CLI conventions: Basic, Rollback, Blue Green, Canary, Rolling, Shadow |
| 224 | +- Use `groupId` to correlate related events across different accounts/environments (recommended: `${{ github.run_id }}-${{ github.sha }}`) |
| 225 | +- For more information, see the [New Relic Change Tracking documentation](https://docs.newrelic.com/docs/change-tracking/change-tracking-events/) |
| 226 | + |
0 commit comments