Compare commits

...

8 commits
v1 ... main

4 changed files with 61 additions and 11 deletions

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"cSpell.words": ["elif", "kaniko"]
}

10
LICENSE Normal file
View file

@ -0,0 +1,10 @@
MIT License
Copyright (c) 2023 s3lph
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,10 +1,10 @@
# Kaniko Action
Build OCI images using Kaniko, with the Dockerfile contents provided directly as an action input.
Build OCI images using Kaniko.
## Usage
Example:
### Example: Basic Usage, all options.
```yaml
jobs:
@ -21,3 +21,22 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
```
### Example: Multiple Tags, Default registry
```yaml
jobs:
cowsay:
runs-on: docker
steps:
- uses: https://github.com/leandro-costa-oliveira/forgejo-kaniko-action@v2
with:
image: my-user/test-image:latest,my-user/test-image:${{ github.sha }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
```
### Credits
Original creator of the action v1:
https://git.kabelsalat.ch/s3lph/forgejo-kaniko-action

View file

@ -1,17 +1,20 @@
---
name: Kaniko
name: Forgejo Kaniko
description: Build a container image using Kaniko
branding:
icon: anchor
color: blue
inputs:
Dockerfile:
dockerfile:
description: The Dockerfile to pass to Kaniko
required: true
required: false
image:
description: Name and tag under which to upload the image
required: true
registry:
description: Domain of the registry. Should be the same as the first path component of the tag.
required: true
required: false
default: https://index.docker.io/v1/
username:
description: Username for the container registry
required: true
@ -27,7 +30,22 @@ runs:
- |
mkdir -p /kaniko/.docker
echo '{"auths":{"${{ inputs.registry }}":{"auth":"'$(printf "%s:%s" "${{ inputs.username }}" "${{ inputs.password }}" | base64 | tr -d '\n')'"}}}' > /kaniko/.docker/config.json
cat > Dockerfile <<EOF
${{ inputs.Dockerfile }}
EOF
/kaniko/executor --dockerfile Dockerfile --destination ${{ inputs.image }}
if [ -n "${{ inputs.dockerfile }}" ]; then
echo "Using Dockerfile from input"
echo "${{ inputs.dockerfile }}" > Dockerfile
elif [ -f "./Dockerfile" ]; then
echo "Using existing ./Dockerfile from workspace"
else
echo "ERROR: No Dockerfile provided and no ./Dockerfile found in workspace"
exit 1
fi
dest_flags=""
for dest in $(echo "${{ inputs.image }}" | tr ',' ' '); do
dest_flags="$dest_flags --destination=$dest"
done
echo "Destinations: $dest_flags"
/kaniko/executor --dockerfile Dockerfile --context $GITHUB_WORKSPACE $dest_flags