diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c60674c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.words": ["elif", "kaniko"] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..39629a2 --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md index 18e8ba3..c3a7b04 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 3d61d87..6856f9f 100644 --- a/action.yml +++ b/action.yml @@ -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 < 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