Skip to content

Commit

Permalink
Add APT and Yum validation with new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffinito committed Aug 1, 2023
1 parent 36658c1 commit 7d2eb28
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/post_deploy_agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Post Deploy for the .NET Agent


on:
workflow_dispatch:
inputs:
agent_version:
description: 'Agent Version to deploy. Needs to match the version from the Release Workflow (all_solutions.yml). Format: X.X.X'
required: true
type: string

workflow_call:
inputs:
agent_version:
description: 'Agent Version to deploy. Needs to match the version from the Release Workflow (all_solutions.yml). Format: X.X.X'
required: true
type: string

permissions:
contents: read
packages: read

env:
DOTNET_NOLOGO: true

jobs:

validate-apt-repo:
name: Validate APT-based repo
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: true
egress-policy: audit

- name: Validate
run: |
echo 'deb https://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add -
apt-get update
apt-get install newrelic-dotnet-agent
installed_version=$(dpkg -s newrelic-dotnet-agent | grep -i version)
if [ "$AGENT_VERSION" = "$installed_version" ]; then
echo "Versions match."
exit 0
else
echo "ERROR: Version mismatch: Expected $AGENT_VERSION was $installed_version"
exit 1
fi
shell: bash
env:
AGENT_VERSION: "Version: ${{ github.event.inputs.agent_version }}"

validate-yum-repo:
name: Validate YUM-based repo
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: true
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Validate
run: |
cd deploy/validation/validate-yum
# This will setup the New Relic yum repo and install the agent.
docker build -t localtesting/validateyum:latest .
docker run --name validateyum localtesting/validateyum:latest
installed_version=$(docker logs --tail 1 validateyum)
if [ "$AGENT_VERSION" = "$installed_version" ]; then
echo "Versions match."
exit 0
else
echo "ERROR: Version mismatch: Expected $AGENT_VERSION was $installed_version"
exit 1
fi
shell: bash
env:
AGENT_VERSION: "newrelic-dotnet-agent-${{ github.event.inputs.agent_version }}-1.x86_64"
9 changes: 9 additions & 0 deletions deploy/validation/validate-yum/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM rockylinux:9

RUN yum install wget -y \
&& wget https://download.newrelic.com/548C16BF.gpg -O /etc/pki/rpm-gpg/RPM-GPG-KEY-NewRelic \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-NewRelic

COPY --chmod=777 check-version.sh /tmp/

ENTRYPOINT ["/tmp/check-version.sh"]
16 changes: 16 additions & 0 deletions deploy/validation/validate-yum/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

cat << REPO | tee "/etc/yum.repos.d/newrelic-dotnet-agent.repo"
[newrelic-dotnet-agent-repo]
name=New Relic .NET Core packages for Enterprise Linux
baseurl=https://yum.newrelic.com/pub/newrelic/el7/\$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-NewRelic
REPO

yum install newrelic-dotnet-agent -y

rpm -q newrelic-dotnet-agent

0 comments on commit 7d2eb28

Please sign in to comment.