Sources:
- Tutorial: Create a GitLab pipeline to push to Google Artifact Registry
- Tutorial: Create and deploy a web service with the Google Cloud Run component
https://docs.gitlab.com/ee/api/deployments.html
It is possible to have a button on a GitLab README page that would deploy an artifact to a particular cloud provider. While the provided documentation doesn't explicitly mention this specific feature, it does discuss CI/CD pipelines and deployment to cloud providers like Google Cloud.
To achieve this, you would typically:
- Set up a CI/CD pipeline in GitLab that handles the deployment process.
- Use GitLab's pipeline syntax in your .gitlab-ci.yml file to define the deployment job.
- In your README.md file, you can add a button that triggers this pipeline manually.
For example, you could add a button like this to your README:
[](https://gitlab.com/your-project/-/pipelines/new)
This button would link to the "Run Pipeline" page for your project, allowing users to manually trigger the deployment pipeline.
The actual deployment process would be defined in your .gitlab-ci.yml file, which could include steps to build your artifact and deploy it to your chosen cloud provider.
Get a single deploy key Get a single key. GET /projects/:id/deploy_keys/:key_id
Parameters:
Attribute Type Required Description id integer/string yes The ID or URL-encoded path of the project owned by the authenticated user key_id integer yes The ID of the deploy key curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/deploy_keys/11"
Example response:
{ "id": 1, "title": "Public key", "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNJAkI3Wdf0r13c8a5pEExB2YowPWCSVzfZV22pNBc1CuEbyYLHpUyaD0GwpGvFdx2aP7lMEk35k6Rz3ccBF6jRaVJyhsn5VNnW92PMpBJ/P1UebhXwsFHdQf5rTt082cSxWuk61kGWRQtk4ozt/J2DF/dIUVaLvc+z4HomT41fQ==", "fingerprint": "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9", "fingerprint_sha256": "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU", "created_at": "2013-10-02T10:12:29Z", "expires_at": null, "can_push": false }
Add deploy key Creates a new deploy key for a project.
If the deploy key already exists in another project, it’s joined to the current project only if the original one is accessible by the same user.
POST /projects/:id/deploy_keys
Attribute Type Required Description
id integer/string yes The ID or URL-encoded path of the project owned by the authenticated user
key string yes New deploy key
title string yes New deploy key’s title
can_push boolean no Can deploy key push to the project’s repository
expires_at datetime no Expiration date for the deploy key. Does not expire if no value is provided. Expected in ISO 8601 format (2019-03-15T08:00:00Z)
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json"
--data '{"title": "My deploy key", "key": "ssh-rsa AAAA...", "can_push": "true"}'
"https://gitlab.example.com/api/v4/projects/5/deploy_keys/"
Example response:
{ "key" : "ssh-rsa AAAA...", "id" : 12, "title" : "My deploy key", "can_push": true, "created_at" : "2015-08-29T12:44:31.550Z", "expires_at": null }
Update deploy key Updates a deploy key for a project.
PUT /projects/:id/deploy_keys/:key_id
Attribute Type Required Description
id integer/string yes The ID or URL-encoded path of the project owned by the authenticated user
can_push boolean no Can deploy key push to the project’s repository
title string no New deploy key’s title
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json"
--data '{"title": "New deploy key", "can_push": true}' "https://gitlab.example.com/api/v4/projects/5/deploy_keys/11"
Example response:
{ "id": 11, "title": "New deploy key", "key": "ssh-rsa AAAA...", "created_at": "2015-08-29T12:44:31.550Z", "expires_at": null, "can_push": true }