Select a repository where you want to create a secret.
Under Repository settings on the repository page, go to Secrets.
On the page with secrets:
If you do not have any secrets yet, click New secret.
If you already have secrets, click Add secret in the top-right corner.
In the window that opens:
In the Name field, enter a name for your secret.
In the Secret field, enter a value for your secret.
Click Add secret.
Using the value of a secret in CI/CD
You can use secret values in the repository's CI/CD processes. To do this, in the .sourcecraft/ci.yaml configuration file, specify the secret in ${{ secrets.<secret_name> }} format.
Example
This tutorial provides the .sourcecraft/ci.yaml configuration file for CI/CD, which runs when you create a pull request to the master branch and does the following:
# To run this CI/CD, create the following resources in Yandex Cloud:# • Yandex Container Registry registry# • Yandex Serverless Containers container# • Service account with the serverless-containers.editor, # container-registry.images.pusher, and iam.serviceAccounts.user roles# • Authorized key to access Container Registry and Serverless Containerson:pull_request:-workflows:ci-cd-container-registry-serverlessfilter:source_branches: ["**", "!test**"]
target_branches:"master"workflows:ci-cd-container-registry-serverless:tasks:-build-push-deploy-serverlesstasks:-name:build-push-deploy-serverlessenv:YC_DOCKER_REGISTRY_URI:cr.yandex/<registry_ID>IMAGE_NAME:<image_name>YC_SERVERLESS_CONTAINER_NAME:<container_name>YC_SERVICE_ACCOUNT_ID:<service_account_ID>YC_AUTHORIZED_KEY_JSON:${{secrets.<secret_name>}}YC_FOLDER_ID:<folder_ID>cubes:-name:install-ycscript:-curl-o./yc-install.sh-Lhttps://storage.yandexcloud.net/yandexcloud-yc/install.sh|bash-s---a-echo'source /root/yandex-cloud/completion.zsh.inc'>>~/.zshrc-chmod+x./yc-install.sh&&./yc-install.sh-i/tmp/yc-n&&mv/tmp/yc/bin/yc/usr/bin/yc-echo"$YC_AUTHORIZED_KEY_JSON">key.json-ycconfigprofilecreatesa-profile-ycconfigsetservice-account-keykey.json-ycconfigsetformatjson-ycconfigsetfolder-id$YC_FOLDER_ID-name:docker-loginscript:-yccontainerregistryconfigure-docker--profilesa-profile-name:docker-build-pushscript:-dockerbuild--tag$YC_DOCKER_REGISTRY_URI/$IMAGE_NAME--platformlinux/amd64.-dockerpush$YC_DOCKER_REGISTRY_URI/$IMAGE_NAME:latest-name:docker-logoutscript:-dockerlogout$YC_DOCKER_REGISTRY_URI-name:create-serverlessscript:-ycserverlesscontainerrevisiondeploy--container-name$YC_SERVERLESS_CONTAINER_NAME--image$YC_DOCKER_REGISTRY_URI/$IMAGE_NAME:latest--service-account-id$YC_SERVICE_ACCOUNT_ID