Add pipeline to publish ghcr multi-arch image (#2268)

Refactor operator image build process
Add a pipeline to build and publish arm64/amd64 image in ghcr on every
pushed tag
This commit is contained in:
Polina Bungina
2023-04-17 15:28:27 +02:00
committed by GitHub
parent fc86c44ec3
commit a9c6d46f7d
5 changed files with 104 additions and 10 deletions
+56
View File
@@ -0,0 +1,56 @@
name: Publish multiarch postgres-operator image on ghcr.io
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
on:
push:
tags:
- '*'
jobs:
publish:
name: Build, test and push image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: "^1.18.9"
- name: Run unit tests
run: make deps mocks test
- name: Define image name
id: image
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//}"
echo "NAME=$IMAGE" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push multiarch image to ghcr
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
push: true
build-args: BASE_IMAGE=alpine:3.15
tags: "${{ steps.image.outputs.NAME }}"
platforms: linux/amd64,linux/arm64
-2
View File
@@ -19,8 +19,6 @@ jobs:
run: make deps mocks
- name: Code generation
run: make codegen
- name: Compile
run: make linux
- name: Run unit tests
run: make test
- name: Run end-2-end tests