While workers may be [run locally](./run-local.md), they are usually written to launch on an Arkindex instance. A worker version on Arkindex is basically a configuration and an URL towards a Docker image, used at runtime during processes. The worker [template](./template-structure.md) includes an automatic publication process towards any Arkindex instance.
## How it works
The template implements a new CI job, `publish-worker`, at the last stage of the pipeline. When every job of the previous stages have passed, this one will try to publish a new worker version, using the newly built Docker image, on every Arkindex instance specified by the `ARKINDEX_INSTANCE` variable. The publication is done using the [Arkindex CLI tool](<https://cli.arkindex.org/workers/#publish-workers>).
!!! warning
If you change the `docker_image_tag` positional argument value, it might not be in sync with the tag produced during the `docker-build` job. Make sure these match to link the version with the right Docker image.
!!! note
If your repository defines multiple workers, one worker version will be pushed per worker. However, there will still only be one job per instance.
## Authentication in CI
Since the publication is done during a GitLab CI, no optional arguments are [needed](<https://cli.arkindex.org/workers/#running-the-command-in-a-gitlab-ci-pipeline>). There are multiple ways to authenticate to an Arkindex instance when using the CLI tool. During a GitLab CI, the best way is through a [Project-level Secure File](<https://docs.gitlab.com/ee/ci/secure_files/>). Make sure to create one that follows the format [supported by the CLI](<https://cli.arkindex.org/login/#gitlab-secure-file>). The template expects that secure file to be named `arkindex-cli.yaml`.
## Specifying another instance
In the template, a publication to <https://demo.arkindex.org> (slug `demo`) is presented. To publish to another instance, make sure that:
- the authentication credentials for that instance are present in the secure file,
- the slug is listed as a potential value for `ARKINDEX_INSTANCE` in the `publish-worker` job configuration.