Skip to content

Commit

Permalink
core: add publish action (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsanchezgavier authored Mar 17, 2021
1 parent 53a276b commit eda1647
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 27 deletions.
68 changes: 53 additions & 15 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ on:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO_VERSION: '1.9.7'
GPG_MAIL: '[email protected]'
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
INTEGRATION: "apache"
ORIGINAL_REPO_NAME: 'newrelic/nri-apache'
PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
TAG: ${{ github.event.release.tag_name }}

jobs:

validate:
name: Validate code via linters
runs-on: ubuntu-20.04
Expand All @@ -39,8 +32,6 @@ jobs:
snyk:
name: Run security checks via snyk
runs-on: ubuntu-20.04
env:
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
Expand All @@ -49,6 +40,8 @@ jobs:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Scan code for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
run: make ci/snyk-test

test-nix:
Expand Down Expand Up @@ -103,11 +96,6 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{env.GO_VERSION}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Integration test
env:
GOPATH: ${{ github.workspace }}
Expand All @@ -126,6 +114,10 @@ jobs:
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Pre release
run: make ci/prerelease
env:
GPG_MAIL: '[email protected]'
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
- name: Notify failure via Slack
if: ${{ failure() }}
uses: archive/github-actions-slack@master
Expand All @@ -145,6 +137,9 @@ jobs:
needs: [prerelease]
env:
GOPATH: ${{ github.workspace }}
PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
defaults:
run:
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
Expand Down Expand Up @@ -188,3 +183,46 @@ jobs:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."

publish-to-s3:
name: Send release assets to S3
runs-on: ubuntu-20.04
needs: [package-win]
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Publish to S3 action
uses: newrelic/infrastructure-publish-action@v1
env:
AWS_S3_BUCKET_NAME: "nr-downloads-ohai-staging"
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock-staging"
with:
disable_lock: false
run_id: ${{ github.run_id }}
tag: ${{env.TAG}}
app_name: "nri-${{env.INTEGRATION}}"
repo_name: ${{ env.ORIGINAL_REPO_NAME }}
# 'ohi' is for integrations
schema: "ohi"
aws_region: "us-east-1"
aws_role_arn: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }}
aws_role_session_name: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }}
aws_access_key_id: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_STAGING }}
aws_secret_access_key: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }}
aws_s3_bucket_name: ${{ env.AWS_S3_BUCKET_NAME }}
# used for locking in case of concurrent releases
aws_s3_lock_bucket_name: ${{ env.AWS_S3_LOCK_BUCKET_NAME }}
# used for signing package stuff
gpg_passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}
gpg_private_key_base64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
- name: Test uploaded package installability
uses: newrelic/integrations-pkg-test-action/linux@v1
with:
tag: ${{ env.TAG }}
integration: nri-${{ env.INTEGRATION }}
packageLocation: repo
stagingRepo: true
upgrade: false
14 changes: 7 additions & 7 deletions .github/workflows/push_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ env:
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
ORIGINAL_REPO_NAME: "newrelic/nri-apache"
GO_VERSION: '1.9.7'
DOCKER_LOGIN_AVAILABLE: ${{ secrets.OHAI_DOCKER_HUB_ID }}

jobs:

validate:
name: Validate code via linters
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
Expand All @@ -36,11 +37,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Scan code for vulnerabilities
if: ${{env.SNYK_TOKEN}}
run: make ci/snyk-test

test-nix:
Expand All @@ -49,6 +52,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
Expand All @@ -63,7 +67,7 @@ jobs:
GOPATH: ${{ github.workspace }}
defaults:
run:
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
working-directory: src/github.com/${{ env.ORIGINAL_REPO_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -95,11 +99,6 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{env.GO_VERSION}}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Integration test
env:
GOPATH: ${{ github.workspace }}
Expand All @@ -111,6 +110,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release pipeline

on:
release:
types:
- released
tags:
- 'v*'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INTEGRATION: "apache"
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
TAG: ${{ github.event.release.tag_name }}

jobs:

publish-to-s3:
name: Send release assets to S3
runs-on: ubuntu-20.04
steps:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Publish to S3 action
uses: newrelic/infrastructure-publish-action@v1
env:
AWS_S3_BUCKET_NAME: "nr-downloads-main"
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock"
AWS_REGION: "us-east-1"
with:
# lock enabled
disable_lock: false
run_id: ${{ github.run_id }}
tag: ${{env.TAG}}
app_name: "nri-${{env.INTEGRATION}}"
repo_name: ${{ env.ORIGINAL_REPO_NAME }}
# 'ohi' is for integrations
schema: "ohi"
aws_region: ${{ env.AWS_REGION }}
aws_role_arn: ${{ secrets.OHAI_AWS_ROLE_ARN_PRODUCTION }}
aws_role_session_name: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_PRODUCTION }}
aws_access_key_id: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
aws_secret_access_key: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
aws_s3_bucket_name: ${{ env.AWS_S3_BUCKET_NAME }}
# used for locking in case of concurrent releases
aws_s3_lock_bucket_name: ${{ env.AWS_S3_LOCK_BUCKET_NAME }}
# used for signing package stuff
gpg_passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}
gpg_private_key_base64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
- name: Test package from prod repo
uses: newrelic/integrations-pkg-test-action/linux@v1
with:
tag: ${{ env.TAG }}
integration: 'nri-${{ env.INTEGRATION }}' # Required, with nri- prefix
packageLocation: repo
upgrade: false
5 changes: 0 additions & 5 deletions CODE_OF_CONDUCT.md

This file was deleted.

1 change: 1 addition & 0 deletions build/ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ci/snyk-test:
-v $(CURDIR):/go/src/github.com/newrelic/nri-$(INTEGRATION) \
-w /go/src/github.com/newrelic/nri-$(INTEGRATION) \
-e SNYK_TOKEN \
-e GO111MODULE=auto \
snyk/snyk:golang snyk test --severity-threshold=high

.PHONY : ci/build
Expand Down

0 comments on commit eda1647

Please sign in to comment.