summaryrefslogtreecommitdiff
path: root/doc/user/packages/composer_repository/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/user/packages/composer_repository/index.md')
-rw-r--r--doc/user/packages/composer_repository/index.md31
1 files changed, 24 insertions, 7 deletions
diff --git a/doc/user/packages/composer_repository/index.md b/doc/user/packages/composer_repository/index.md
index 9b1f23f6d59..89e02b4847c 100644
--- a/doc/user/packages/composer_repository/index.md
+++ b/doc/user/packages/composer_repository/index.md
@@ -79,12 +79,17 @@ git push origin v1.0.0
Now that the basics of our project is completed, we can publish the package.
To publish the package, you need:
-- A personal access token. You can generate a [personal access token](../../../user/profile/personal_access_tokens.md) with the scope set to `api` for repository authentication.
+- A personal access token or `CI_JOB_TOKEN`.
+
+ ([Deploy tokens](./../../project/deploy_tokens/index.md) are not yet supported for use with Composer.)
+
- Your project ID which can be found on the home page of your project.
To publish the package hosted on GitLab, make a `POST` request to the GitLab package API.
A tool like `curl` can be used to make this request:
+You can generate a [personal access token](../../../user/profile/personal_access_tokens.md) with the scope set to `api` for repository authentication. For example:
+
```shell
curl --data tag=<tag> 'https://__token__:<personal-access-token>@gitlab.com/api/v4/projects/<project_id>/packages/composer'
```
@@ -97,6 +102,21 @@ Where:
If the above command succeeds, you now should be able to see the package under the **Packages & Registries** section of your project page.
+### Publishing the package with CI/CD
+
+To work with Composer commands within [GitLab CI/CD](./../../../ci/README.md), you can
+publish Composer packages by using `CI_JOB_TOKEN` in your `.gitlab-ci.yml` file:
+
+```yaml
+stages:
+ - deploy
+
+deploy:
+ stage: deploy
+ script:
+ - 'curl --header "Job-Token: $CI_JOB_TOKEN" --data tag=<tag> "https://gitlab.example.com/api/v4/projects/$CI_PROJECT_ID/packages/composer"'
+```
+
### Installing a package
To install your package, you need:
@@ -130,11 +150,8 @@ You also need to create a `auth.json` file with your GitLab credentials:
```json
{
- "http-basic": {
- "gitlab.com": {
- "username": "___token___",
- "password": "<personal_access_token>"
- }
+ "gitlab-token": {
+ "gitlab.com": "<personal_access_token>"
}
}
```
@@ -155,4 +172,4 @@ CAUTION: **Important:**
Make sure to never commit the `auth.json` file to your repository. To install packages from a CI job,
consider using the [`composer config`](https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#authentication) tool with your personal access token
stored in a [GitLab CI/CD environment variable](../../../ci/variables/README.md) or in
-[Hashicorp Vault](../../../ci/examples/authenticating-with-hashicorp-vault/index.md).
+[Hashicorp Vault](../../../ci/secrets/index.md).