From 48380cbf081aec99963d57e80975385ec792bd34 Mon Sep 17 00:00:00 2001 From: Ramiro Berrelleza Date: Mon, 24 Jul 2023 15:36:05 -0700 Subject: [PATCH 1/5] updated parameters --- entrypoint.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index be3ac1b..ba13e80 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,24 +1,36 @@ #!/bin/sh set -e +tag=$1 file=$2 +path=$3 +buildargs=$4 global=$5 -BUILDPARAMS="" - if [ ! -z "$OKTETO_CA_CERT" ]; then echo "Custom certificate is provided" echo "$OKTETO_CA_CERT" > /usr/local/share/ca-certificates/okteto_ca_cert.crt update-ca-certificates fi -params=$(eval echo --progress plain -f "$file") +params="" + +if [ ! -z $tag ]; then +params="${params} --tag=${tag}" +fi + +if [ ! -z $file ]; then +params="${params} --file=${file}" +fi + +if [ ! -z $global ]; then +params="${params} --global" +fi -if [ "$global" = "true" ]; then - params="${params} --global" +if [ ! -z $buildargs ]; then +params="${params} --buildargs=${buildargs}" fi -params=$(eval echo "$params") echo running: okteto build $params okteto build $params \ No newline at end of file From 8d1162572f7224eb0f28d412d2a86073f58693d5 Mon Sep 17 00:00:00 2001 From: Ramiro Berrelleza Date: Mon, 24 Jul 2023 15:52:52 -0700 Subject: [PATCH 2/5] update parameters and readme --- README.md | 96 +++++++++++++++++++++++++++++++++++++-------------- entrypoint.sh | 21 ++++++----- 2 files changed, 83 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 78cede4..cb866d4 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,25 @@ You can use this action to build images from an [Okteto Manifest](https://www.ok ## Inputs +### `tag` + +The name and (optionally) a tag to use for the impage, in the 'name:tag' format. If specified, the action will automatically push the image on a succesfull build. + + ### `file` -The path to the Okteto Manifest. Default `"okteto.yml"`. -Name of the Dockerfile. Default `"Dockerfile"`. +The relative path to the Okteto Manifest. Default `"okteto.yaml"`. + +> You can also use this input to point to a Dockerfile. In this mode, okteto build will ignore your Okteto manifest, and directly build the image defined in the Dockerfile. Use this to build images that are not defined on your Okteto manifest. + +### `path` + +The execution path of the action. + + +### `buildargs` + +A list of comma-separated build arguments. ### `global` @@ -24,7 +39,7 @@ Only admins can push images to the global registry. ## Example usage -This example runs the context action and then builds and pushes an image. +This example sets the context, and then builds the images defined on the default `okteto.yaml` file. ```yaml # File: .github/workflows/workflow.yml @@ -48,33 +63,62 @@ jobs: ## Advanced usage - ### Custom Certification Authorities or Self-signed certificates +### Build an image that is not defined in the manifest - You can specify a custom certificate authority or a self-signed certificate by setting the `OKTETO_CA_CERT` environment variable. When this variable is set, the action will install the certificate in the container, and then execute the action. +This example sets the context, and then builds an image that is not defined in the Okteto manifest - Use this option if you're using a private Certificate Authority or a self-signed certificate in your [Okteto Enterprise](http://okteto.com/enterprise) instance. We recommend that you store the certificate as an [encrypted secret](https://docs.github.com/en/actions/reference/encrypted-secrets), and that you define the environment variable for the entire job, instead of doing it on every step. - - - ```yaml - # File: .github/workflows/workflow.yml - on: [push] +```yaml +# File: .github/workflows/workflow.yml +on: [push] - name: example +name: example - jobs: - devflow: - runs-on: ubuntu-latest - env: - OKTETO_CA_CERT: ${{ secrets.OKTETO_CA_CERT }} - steps: +jobs: - - name: checkout - uses: actions/checkout@master - - - uses: okteto/context@latest - with: - token: ${{ secrets.OKTETO_TOKEN }} - + devflow: + runs-on: ubuntu-latest + steps: + + - uses: okteto/context@latest + with: + token: ${{ secrets.OKTETO_TOKEN }} + - name: "Build" uses: okteto/build@latest - ``` + with: + tag: registry.okteto.example.com/okteto/web-deps-cache:latest + file: deps-cache.Dockerfile + path: web +``` + + +### Custom Certification Authorities or Self-signed certificates + +You can specify a custom certificate authority or a self-signed certificate by setting the `OKTETO_CA_CERT` environment variable. When this variable is set, the action will install the certificate in the container, and then execute the action. + +Use this option if you're using a private Certificate Authority or a self-signed certificate in your [Okteto Enterprise](http://okteto.com/enterprise) instance. We recommend that you store the certificate as an [encrypted secret](https://docs.github.com/en/actions/reference/encrypted-secrets), and that you define the environment variable for the entire job, instead of doing it on every step. + + +```yaml +# File: .github/workflows/workflow.yml +on: [push] + +name: example + +jobs: + devflow: + runs-on: ubuntu-latest + env: + OKTETO_CA_CERT: ${{ secrets.OKTETO_CA_CERT }} + steps: + + - name: checkout + uses: actions/checkout@master + + - uses: okteto/context@latest + with: + token: ${{ secrets.OKTETO_TOKEN }} + + - name: "Build" + uses: okteto/build@latest +``` diff --git a/entrypoint.sh b/entrypoint.sh index ba13e80..f585354 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,7 +7,7 @@ path=$3 buildargs=$4 global=$5 -if [ ! -z "$OKTETO_CA_CERT" ]; then +if [ -n "$OKTETO_CA_CERT" ]; then echo "Custom certificate is provided" echo "$OKTETO_CA_CERT" > /usr/local/share/ca-certificates/okteto_ca_cert.crt update-ca-certificates @@ -15,22 +15,27 @@ fi params="" -if [ ! -z $tag ]; then +if [ -n "$tag" ]; then params="${params} --tag=${tag}" fi -if [ ! -z $file ]; then +if [ -n "$file" ]; then params="${params} --file=${file}" fi -if [ ! -z $global ]; then +if [ "$global" = "true" ]; then params="${params} --global" fi -if [ ! -z $buildargs ]; then -params="${params} --buildargs=${buildargs}" +if [ -n "$buildargs" ]; then +IFS=',' ;for i in $buildargs; do + params="${params} --build-arg=${i}" +done fi +if [ -n "$path" ]; then +cd "$path" +fi -echo running: okteto build $params -okteto build $params \ No newline at end of file +echo running: "okteto build $params" +#okteto build $params \ No newline at end of file From b2184122a8726edc9755eae01fb18384b9cf3934 Mon Sep 17 00:00:00 2001 From: Ramiro Berrelleza Date: Mon, 24 Jul 2023 15:54:49 -0700 Subject: [PATCH 3/5] remove comment on final command --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index f585354..0c1d9c4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -38,4 +38,4 @@ cd "$path" fi echo running: "okteto build $params" -#okteto build $params \ No newline at end of file +okteto build $params \ No newline at end of file From e79e926ec539a89b8e4bb9c5af44a5001dbd38fa Mon Sep 17 00:00:00 2001 From: Ramiro Berrelleza Date: Mon, 24 Jul 2023 16:00:13 -0700 Subject: [PATCH 4/5] print version --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 0c1d9c4..7d457c7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -38,4 +38,5 @@ cd "$path" fi echo running: "okteto build $params" +okteto version okteto build $params \ No newline at end of file From fd0967be3b02bb978a184d75703b10aa4ef10edb Mon Sep 17 00:00:00 2001 From: Ramiro Berrelleza Date: Mon, 24 Jul 2023 16:06:19 -0700 Subject: [PATCH 5/5] use 2.18.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aac44bd..104258b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM okteto/okteto:latest +FROM okteto/okteto:2.18.0 COPY entrypoint.sh /entrypoint.sh