Skip to content

Update docker-push.yml (#25) #2

Update docker-push.yml (#25)

Update docker-push.yml (#25) #2

Workflow file for this run

name: Docker push
on:
push:
tags:
- manager/v[0-9]+.[0-9]+.[0-9]+-*
concurrency: release-${{ github.event.release.tag_name }}
env:
REGISTRY: ghcr.io
defaults:
run:
shell: bash
jobs:
docker_build_and_push:
name: Docker build and push
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Prepare repository name
id: prepare-repository-name
run: |
repository=$REGISTRY/${{ github.repository }}/cap-operator-manager
echo "repository=${repository,,}" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: extract-metadata
uses: docker/metadata-action@v4
with:
images: ${{ steps.prepare-repository-name.outputs.repository }}
tags: |
type=match,pattern=manager/v(.*),group=1,value=${{ github.event.release.tag_name }}
- name: Build and push docker image
uses: docker/build-push-action@v4
with:
file: Dockerfile
platforms: linux/amd64,linux/arm64
context: .
cache-from: |
type=gha,scope=sha-${{ github.sha }}
type=gha,scope=${{ github.ref_name }}
type=gha,scope=${{ github.base_ref || 'main' }}
type=gha,scope=main
cache-to: |
type=gha,scope=sha-${{ github.sha }},mode=max
type=gha,scope=${{ github.ref_name }},mode=max
push: true
tags: ${{ steps.extract-metadata.outputs.tags }}
labels: ${{ steps.extract-metadata.outputs.labels }}
- name: Print Outputs
run: |
echo "Tags: ${{ steps.extract-metadata.outputs.tags }}"
echo "Labels: ${{ steps.extract-metadata.outputs.labels }}"