Skip to content

Commit

Permalink
Merge branch 'main' into fix-devcontainer-pyenv
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 23, 2023
2 parents 099bf8c + 4721025 commit 205fb52
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
109 changes: 109 additions & 0 deletions .github/actions/update-rpm-config/action.yml
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
10 changes: 10 additions & 0 deletions .github/workflows/deploy-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@ jobs:
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

- name: Update RPM Config
uses: ./.github/actions/update-rpm-config
with:
agent-language: "python"
target-system: "all"
agent-version: "${{ github.ref_name }}"
dry-run: "false"
production-api-key: ${{ secrets.NEW_RELIC_API_KEY_PRODUCTION }}"
staging-api-key: ${{ secrets.NEW_RELIC_API_KEY_STAGING }}"
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"
Expand Down

0 comments on commit 205fb52

Please sign in to comment.