Task Registration on Legacy Workers
If your worker was created before local task registration was supported, follow the steps below to enable it.
Step 1: SDK version
Ensure your project uses version 3.6.0 or higher of @picsart/pa-pluggable-workers-core
Step 2: Update package.json
Add the following scripts to your package.json.
{
"scripts": {
"register-tasks": "register-task-definitions",
"register-tasks:dev": "node -r dotenv/config node_modules/.bin/register-task-definitions",
}
}
Step 3: Update CI
Update your .gitlab-ci.yml file with the following changes:
## Update stages
stages:
- test
- build
- register-tasks
- deploy
## Add new jobs .............
.register-task:
image: node:20
stage: register-tasks
needs:
- build
- compute-version
environment:
name: $DEPLOYMENT_ENV
before_script:
- cd server
- |
{
echo "//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}"
} | tee -a .npmrc
script:
- npm ci --cache ./cache
- npm run register-tasks
register-tasks-dev:
extends: [.register-task]
rules:
- if: $CI_COMMIT_REF_NAME == "main" && $CI_PIPELINE_SOURCE != "schedule"
variables:
DEPLOYMENT_ENV: development
register-tasks-stage:
extends: [.register-task]
rules:
- if: $CI_COMMIT_REF_NAME == "main"
variables:
DEPLOYMENT_ENV: stage
register-tasks-prod:
extends: [.register-task]
rules:
- if: $CI_COMMIT_TAG =~ $TAG_VERSION_REGEX
variables:
DEPLOYMENT_ENV: prod
note
Make sure task registration jobs complete successfully before deployment, just like in the template.