feat: initial push

This commit is contained in:
Marc 2024-11-07 22:23:43 -05:00
commit ad14947957
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 56 additions and 0 deletions

21
README.md Normal file
View file

@ -0,0 +1,21 @@
# Push Container Images Forgejo Action
An action that handles pushing multiple images and tags to a given registry.
## Interface
```yml
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
```

35
action.yml Normal file
View file

@ -0,0 +1,35 @@
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