-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-devcontainer-pyenv
- Loading branch information
Showing
3 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: "update-rpm-config" | ||
description: "Set current version of agent in rpm config using API." | ||
inputs: | ||
agent-language: | ||
description: "Language agent to configure (eg. python)" | ||
required: true | ||
default: "python" | ||
target-system: | ||
description: "Target System: prod|staging|all" | ||
required: true | ||
default: "all" | ||
agent-version: | ||
description: "3-4 digit agent version number (eg. 1.2.3) with optional leading v (ignored)" | ||
required: true | ||
dry-run: | ||
description: "Dry Run" | ||
required: true | ||
default: "false" | ||
production-api-key: | ||
description: "API key for New Relic Production" | ||
required: false | ||
staging-api-key: | ||
description: "API key for New Relic Staging" | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Trim potential leading v from agent version | ||
shell: bash | ||
run: | | ||
AGENT_VERSION=${{ inputs.agent-version }} | ||
echo "AGENT_VERSION=${AGENT_VERSION#"v"}" >> $GITHUB_ENV | ||
- name: Generate Payload | ||
shell: bash | ||
run: | | ||
echo "PAYLOAD='{ \"system_configuration\": { \"key\": \"${{ inputs.agent-language }}_agent_version\", \"value\": \"${{ env.AGENT_VERSION }}\" } }'" >> $GITHUB_ENV | ||
- name: Generate Content-Type | ||
shell: bash | ||
run: | | ||
echo "CONTENT_TYPE='Content-Type: application/json'" >> $GITHUB_ENV | ||
- name: Update Staging system configuration page | ||
shell: bash | ||
if: ${{ inputs.dry-run == 'false' && (inputs.target-system == 'staging' || inputs.target-system == 'all') }} | ||
run: | | ||
curl -X POST 'https://staging-api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:${{ inputs.staging-api-key }}" -i \ | ||
-H ${{ env.CONTENT_TYPE }} \ | ||
-d ${{ env.PAYLOAD }} | ||
- name: Update Production system configuration page | ||
shell: bash | ||
if: ${{ inputs.dry-run == 'false' && (inputs.target-system == 'prod' || inputs.target-system == 'all') }} | ||
run: | | ||
curl -X POST 'https://api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:${{ inputs.production-api-key }}" -i \ | ||
-H ${{ env.CONTENT_TYPE }} \ | ||
-d ${{ env.PAYLOAD }} | ||
- name: Verify Staging system configuration update | ||
shell: bash | ||
if: ${{ inputs.dry-run == 'false' && (inputs.target-system == 'staging' || inputs.target-system == 'all') }} | ||
run: | | ||
STAGING_VERSION=$(curl -X GET 'https://staging-api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:${{ inputs.staging-api-key }}" \ | ||
-H "${{ env.CONTENT_TYPE }}" | jq ".system_configurations | from_entries | .${{inputs.agent-language}}_agent_version") | ||
if [ "${{ env.AGENT_VERSION }}" != "$STAGING_VERSION" ]; then | ||
echo "Staging version mismatch: $STAGING_VERSION" | ||
exit 1 | ||
fi | ||
- name: Verify Production system configuration update | ||
shell: bash | ||
if: ${{ inputs.dry-run == 'false' && (inputs.target-system == 'prod' || inputs.target-system == 'all') }} | ||
run: | | ||
PROD_VERSION=$(curl -X GET 'https://api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:${{ inputs.production-api-key }}" \ | ||
-H "${{ env.CONTENT_TYPE }}" | jq ".system_configurations | from_entries | .${{inputs.agent-language}}_agent_version") | ||
if [ "${{ env.AGENT_VERSION }}" != "$PROD_VERSION" ]; then | ||
echo "Production version mismatch: $PROD_VERSION" | ||
exit 1 | ||
fi | ||
- name: (dry-run) Update Staging system configuration page | ||
shell: bash | ||
if: ${{ inputs.dry-run != 'false' && (inputs.target-system == 'staging' || inputs.target-system == 'all') }} | ||
run: | | ||
cat << EOF | ||
curl -X POST 'https://staging-api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:**REDACTED**" -i \ | ||
-H ${{ env.CONTENT_TYPE }} \ | ||
-d ${{ env.PAYLOAD }} | ||
EOF | ||
- name: (dry-run) Update Production system configuration page | ||
shell: bash | ||
if: ${{ inputs.dry-run != 'false' && (inputs.target-system == 'prod' || inputs.target-system == 'all') }} | ||
run: | | ||
cat << EOF | ||
curl -X POST 'https://api.newrelic.com/v2/system_configuration.json' \ | ||
-H "X-Api-Key:**REDACTED**" -i \ | ||
-H ${{ env.CONTENT_TYPE }} \ | ||
-d ${{ env.PAYLOAD }} | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters