Skip to content

Commit

Permalink
Moved to reuable release workflow (#104)
Browse files Browse the repository at this point in the history
* Moved to reuable release workflow

* points to the correct workflow

* No longer use build push action

* Testing nri-statsd with default platforms

* back to using docker platforms input

* pointing to the right workflow for merge

* Undo changelog unreleased section
  • Loading branch information
rahulreddy15 authored Jan 20, 2025
1 parent ecff026 commit d4ad421
Showing 1 changed file with 25 additions and 116 deletions.
141 changes: 25 additions & 116 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,123 +6,32 @@ on:
- prereleased
- released

env:
ORIGINAL_REPO_NAME: "newrelic/nri-statsd"
DOCKER_PLATFORMS: "linux/amd64,linux/arm64"
DOCKER_IMAGE_NAME: newrelic/nri-statsd
TAG: ${{ github.event.release.tag_name }}
VERSION: ""
TAG_SUFFIX: ""

jobs:
integration-tests:
name: 🚧 integration tests
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ arm64, amd64 ]
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}

- name: Running integration tests
run: |
make integration-tests-${{ matrix.arch }}
release-integration:
name: Publish container images to registry
runs-on: ubuntu-latest
needs: [integration-tests]
steps:
- name: Checkout master
uses: actions/checkout@v4

- name: Add pre-release tag suffix
if: ${{ github.event.release.prerelease }}
run: |
echo "TAG_SUFFIX=-pre" >> $GITHUB_ENV
- name: Generate version from tag
run: |
TAG_WITHOUT_V=$(echo "${{ env.TAG }}" | sed 's/^v//')
echo "VERSION=$TAG_WITHOUT_V" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}

- name: Build and push docker image
uses: docker/build-push-action@v6
with:
platforms: ${{ env.DOCKER_PLATFORMS }}
context: .
push: true
tags: |
${{ env.DOCKER_IMAGE_NAME }}:${{ env.VERSION }}${{ env.TAG_SUFFIX }}
- name: Push latest tag
if: ${{ ! github.event.release.prerelease }}
uses: docker/build-push-action@v5
with:
platforms: ${{ env.DOCKER_PLATFORMS }}
context: .
push: true
tags: ${{ env.DOCKER_IMAGE_NAME }}:latest

- name: Update title for successful pre-release
if: ${{ github.event.release.prerelease }}
env:
GH_TOKEN: "${{ secrets.COREINT_BOT_TOKEN }}"
run: |
gh release edit ${{ env.TAG }} --title "${{ env.TAG }}"
container-release:
uses: newrelic/coreint-automation/.github/workflows/reusable_image_release.yaml@v3
with:
original_repo_name: "newrelic/nri-statsd"
docker_image_name: "newrelic/nri-statsd"

# Cannot use default: base image does not support arm/v7
docker_platforms: "linux/amd64,linux/arm64"

notify-failure:
if: ${{ always() && failure() }}
needs: [release-integration]
runs-on: ubuntu-latest
steps:
- name: Notify failure via Slack
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: [image release failed](${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }})."
go_version_file: "tests/integration/go.mod"

update-title-on-failure:
if: ${{ always() && failure() }}
needs: [release-integration]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- if: ${{ github.event.release.prerelease }}
name: Reflect failure in pre-release title
env:
GH_TOKEN: "${{ secrets.COREINT_BOT_TOKEN }}"
run: |
gh release edit ${{ github.event.release.tag_name }} --title "${{ github.event.release.tag_name }} (pre-release-failure)"
run_integration_tests: true

- if: ${{ ! github.event.release.prerelease }}
name: Reflect failure in release title
env:
GH_TOKEN: "${{ secrets.COREINT_BOT_TOKEN }}"
run: |
gh release edit ${{ github.event.release.tag_name }} --title "${{ github.event.release.tag_name }} (release-failure)"
release_command_sh: |
docker buildx build --push --platform=$DOCKER_PLATFORMS \
-t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG \
.
if [[ "${{ github.event.release.prerelease }}" == "false" ]]; then
DOCKER_IMAGE_TAG=latest
docker buildx build --push --platform=$DOCKER_PLATFORMS \
-t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG \
.
fi
secrets:
docker_username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
docker_password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
bot_token: ${{ secrets.COREINT_BOT_TOKEN }}

0 comments on commit d4ad421

Please sign in to comment.