ci: the integration branch script can now update an existing branch
What does this MR do?
ci: the integration branch script can now update an existing branch
This updates the bin/create_integration_branch.mjs
script so that it
detects when the integration branch already exists and pushes to it
instead of trying to re-create it.
Remote verification
The normal developer workflow would look like this:
- Push a development branch to GitLab UI.
- In the latest pipeline, run the
create_integration_branch
job. This creates the integration branch. - Push some more changes to the GitLab UI branch.
- In the latest pipeline, run the
create_integration_branch
job. This updates the integration branch.
This process can be verified right here:
- In this MR's first pipeline, I've run the
create_integration_branch
job, which did create the integration branch:- Job output: https://gitlab.com/gitlab-org/gitlab-ui/-/jobs/7822610802
- Commit that was pushed to the integrations fork: gitlab-org/frontend/gitlab-ui-integrations@a28ba003
- I then ran another pipeline in this MR and triggered the
create_integration_branch
there too, which ended up updating the previously created integration branch:- Job output: https://gitlab.com/gitlab-org/gitlab-ui/-/jobs/7822694353
- Commit that was pushed to the integration branch: gitlab-org/frontend/gitlab-ui-integrations@06756739
Test locally
You will need a Project Access Token with the api
scope in the https://gitlab.com/gitlab-org/frontend/gitlab-ui-integrations project. As a maintainer of GitLab UI, you may copy the one from the GITLAB_INTEGRATION_REST_TOKEN
CI variable: https://gitlab.com/gitlab-org/gitlab-ui/-/settings/ci_cd.
-
Expose the necessary environment variables:
export CI_COMMIT_REF_NAME="<your_branh_name>" # The integration branch suffix of your choice export GITLAB_INTEGRATION_REST_TOKEN="<project_access_token>" export DEPENDENCY_URL="https://gitlab.com/gitlab-org/gitlab-ui/-/jobs/<job_id>artifacts/raw/<archive>.tgz" # The URL provided by any `build` CI job in the GitLab UI project
-
Run the script:
bin/create_integration_branch.mjs
This should create a new branch in the fork.
-
Change the
DEPENDENCY_URL
environment variable to some other package URL:export DEPENDENCY_URL="https://gitlab.com/gitlab-org/gitlab-ui/-/jobs/<job_id>artifacts/raw/<archive>.tgz"
-
Run the script again:
bin/create_integration_branch.mjs
The branch that was created at step
#2
should get updated with the newDEPENDENCY_URL
.