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 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 be3ac1b..7d457c7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,24 +1,42 @@ #!/bin/sh set -e +tag=$1 file=$2 +path=$3 +buildargs=$4 global=$5 -BUILDPARAMS="" - -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 fi -params=$(eval echo --progress plain -f "$file") +params="" + +if [ -n "$tag" ]; then +params="${params} --tag=${tag}" +fi + +if [ -n "$file" ]; then +params="${params} --file=${file}" +fi if [ "$global" = "true" ]; then - params="${params} --global" +params="${params} --global" +fi + +if [ -n "$buildargs" ]; then +IFS=',' ;for i in $buildargs; do + params="${params} --build-arg=${i}" +done fi -params=$(eval echo "$params") +if [ -n "$path" ]; then +cd "$path" +fi -echo running: okteto build $params +echo running: "okteto build $params" +okteto version okteto build $params \ No newline at end of file