Skip to content

Merge pull request #135 from rabbitmq/dependabot/go_modules/all-4f9d8… #147

Merge pull request #135 from rabbitmq/dependabot/go_modules/all-4f9d8…

Merge pull request #135 from rabbitmq/dependabot/go_modules/all-4f9d8… #147

name: Build, Test, & Publish
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
tags:
- "**"
pull_request:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
jobs:
unit_tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Unit tests
run: go test -v ./...
build_dev_image:
name: Build dev image
runs-on: ubuntu-latest
needs: unit_tests
permissions:
contents: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: OCI Metadata for multi-arch image
id: meta
uses: docker/metadata-action@v5
with:
images: |
rabbitmqoperator/default-user-credential-updater
tags: |
type=sha
type=ref,event=pr
type=semver,pattern={{version}}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# We want to always build the image, and push to registry only on new tag i.e. new release
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
push: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release:
name: Release to GitHub Releases
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [ unit_tests, build_dev_image ]
steps:
- uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
generate_release_notes: true
draft: true