Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nr 341876 make docker images pre release uniform #477

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 26 additions & 81 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,32 @@
---
name: Container release
on:
release:
types: [ prereleased, released ]
env:
ORIGINAL_REPO_NAME: 'newrelic/infrastructure-bundle'
jobs:
build:
name: Build and push image
runs-on: ubuntu-latest
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
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
# The DOCKER_IMAGE_TAG var is generated here from the release tag, after some validation
- name: Generate docker image version from git tag
run: |
echo "${{ github.event.release.tag_name }}" | grep -E '^[v]?[0-9.]*[0-9]$'
DOCKER_IMAGE_TAG=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_ENV
# On prereleases, "-rc" is appended to DOCKER_IMAGE_TAG
- if: ${{ github.event.release.prerelease }}
run: |
echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}-rc" >> $GITHUB_ENV

# Download integrations
- name: Download integrations
run: go run downloader.go

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

- name: Build and push versioned docker image
run: ./docker-build.sh . --push
- name: Build and push :latest docker image
if: ${{ ! github.event.release.prerelease }}
env:
DOCKER_IMAGE_TAG: latest
run: ./docker-build.sh . --push

- if: ${{ github.event.release.prerelease }}
uses: actions/checkout@v4
- if: ${{ github.event.release.prerelease }}
name: Update title for successful pre-release
env:
GH_TOKEN: "${{ secrets.COREINT_BOT_TOKEN }}"
run: |
gh release edit ${{ github.event.release.tag_name }} --title "${{ github.event.release.tag_name }}"

notify-failure:
if: ${{ always() && failure() }}
needs: [build]
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.CAOS_COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: [release pipeline failed](${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }})."
jobs:
container-release:
uses: newrelic/coreint-automation/.github/workflows/reusable_image_release.yaml@v3
with:
original_repo_name: 'newrelic/infrastructure-bundle'
docker_image_name: 'newrelic/infrastructure-bundle'
docker_platforms: 'linux/amd64,linux/arm64'
go_version_file: 'go.mod'

run_nix_unit_tests: false
run_windows_unit_tests: false
run_integration_tests: false

use_build_push_action: false
use_custom_release: true

update-release-title-on-failure:
if: ${{ always() && failure() }}
needs: [build]
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)"
- 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: |
go run downloader.go
./docker-build.sh . --push
if [[ "${{ github.event.release.prerelease }}" == "false" ]]; then
DOCKER_IMAGE_TAG=latest ./docker-build.sh . --push
fi

secrets:
docker_username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
docker_password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
bot_token: ${{ secrets.COREINT_BOT_TOKEN }}
Loading