push-container-images-action/action.yml

36 lines
1.3 KiB
YAML
Raw Permalink Normal View History

2024-11-08 03:23:43 +00:00
name: Push Container Images
inputs:
image-prefix:
description: Image name prefix to identify images to push.
required: true
registry-user:
description: Username for registry authentication.
required: true
registry-token:
description: Token/password for registry authentication.
required: true
registry-endpoint:
description: Registry endpoint to authenticate with and push to.
required: true
runs:
using: composite
steps:
- name: Login to Registry
run: podman login -u ${{ inputs.registry-user }} -p ${{ inputs.registry-token }} ${{ inputs.registry-endpoint }}
- name: Set image metadata
id: image-metadata
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Push tagged images to registry
run: |
for image in $(podman image ls --format {{.Repository}} | grep localhost/${{ inputs.image-prefix }})
do
for tag in latest ${{ steps.image-metadata.outputs.image-tag }} ${{ github.ref_name }}
do
SRC=$image:latest
DEST=${{ inputs.registry-endpoint }}/$image:$tag
echo "Pushing $SRC to $DEST"
podman push $SRC $DEST
done
done