-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore: Add a CircleCI parameter for target publish-binary branch #32665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
cacieprins
wants to merge
1
commit into
develop
Choose a base branch
from
ci/parameterize-binary-branch
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ base-internal-minimum-node: &base-internal-minimum-node cypress/base-internal:20 | |
ubuntu-2004-current: &ubuntu-2004-current ubuntu-2004:2024.11.1 | ||
ubuntu-2004-older: &ubuntu-2004-older ubuntu-2004:2024.05.1 | ||
|
||
parameters: | ||
publish-binary-branch: | ||
type: string | ||
default: main | ||
|
||
orbs: | ||
browser-tools: circleci/[email protected] | ||
|
||
|
@@ -1365,19 +1370,6 @@ commands: | |
paths: | ||
- cypress/cypress.zip | ||
|
||
trigger-publish-binary-pipeline: | ||
steps: | ||
- run: | ||
name: "Trigger publish-binary pipeline" | ||
command: | | ||
source ./scripts/ensure-node.sh | ||
echo $SHOULD_PERSIST_ARTIFACTS | ||
node ./scripts/binary/trigger-publish-binary-pipeline.js | ||
- persist_to_workspace: | ||
root: ~/ | ||
paths: | ||
- triggered_pipeline.json | ||
|
||
build-cypress-npm-package: | ||
parameters: | ||
executor: | ||
|
@@ -2473,7 +2465,8 @@ jobs: | |
- restore_cached_workspace | ||
- check-if-binary-exists | ||
- setup_should_persist_artifacts | ||
- trigger-publish-binary-pipeline | ||
- trigger-publish-binary-pipeline: | ||
target-repo-branch: << pipeline.parameters.publish-binary-branch >> | ||
|
||
get-published-artifacts: | ||
<<: *defaults | ||
|
74 changes: 74 additions & 0 deletions
74
.circleci/src/pipeline/commands/trigger-publish-binary-pipeline.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
parameters: | ||
target-repo-branch: | ||
type: string | ||
default: main | ||
|
||
steps: | ||
- run: | ||
name: Trigger publish-binary pipeline | ||
command: | | ||
if [[ -z "$CIRCLE_TOKEN" ]] || \ | ||
[[ -z "$CIRCLE_SHA1" ]] || \ | ||
[[ -z "$CIRCLE_JOB" ]] || \ | ||
[[ -z "$CIRCLE_WORKFLOW_ID" ]] || \ | ||
[[ -z "$CIRCLE_BUILD_URL" ]] || \ | ||
[[ -z "$CIRCLE_BRANCH" ]]; then | ||
|
||
echo "Missing required environment variables. Skipping pipeline trigger." | ||
exit 1 | ||
fi | ||
if [[ -n "$SHOULD_PERSIST_ARTIFACTS" && "$SHOULD_PERSIST_ARTIFACTS" != "true" && "$SHOULD_PERSIST_ARTIFACTS" != "false" ]]; then | ||
echo "SHOULD_PERSIST_ARTIFACTS must be true, false, or undefined. Skipping pipeline trigger." | ||
exit 1 | ||
fi | ||
if [[ -z $(which node) ]] || [[ -z $(which curl) ]] || [[ -z $(which jq) ]]; then | ||
echo "Missing required commands. Skipping pipeline trigger. Ensure: jo, jq, curl, node are installed." | ||
exit 1 | ||
fi | ||
echo "Determining next binary version..." | ||
export NEXT_VERSION=$(node ./scripts/get-next-version.js) | ||
if [[ $? != 0 ]]; then | ||
echo "Failed to determine next binary version. Skipping pipeline trigger." | ||
exit 1 | ||
fi | ||
echo "Next binary version: $NEXT_VERSION" | ||
export BODY=$(cat \<<JSON_BODY_EOF | ||
{ | ||
"branch": "<< parameters.target-repo-branch >>", | ||
"parameters": { | ||
"temp_dir": "${TMPDIR:-/tmp}", | ||
"sha": "$CIRCLE_SHA1", | ||
"job_name": "$CIRCLE_JOB", | ||
"triggered_workflow_id": "$CIRCLE_WORKFLOW_ID", | ||
"triggered_job_url": "$CIRCLE_BUILD_URL", | ||
"branch": "$CIRCLE_BRANCH", | ||
"should_persist_artifacts": ${SHOULD_PERSIST_ARTIFACTS:-false}, | ||
"binary_version": "$NEXT_VERSION" | ||
} | ||
} | ||
JSON_BODY_EOF | ||
) | ||
if [[ $? != 0 ]]; then | ||
echo "Failed to compose the request body. Skipping pipeline trigger." | ||
exit 1 | ||
fi | ||
|
||
echo "Triggering new pipeline in cypress-publish-binary project on branch << parameters.target-repo-branch >>..." | ||
curl -X POST \ | ||
-o ~/triggered_pipeline.json \ | ||
-H "Circle-Token: $CIRCLE_TOKEN" \ | ||
-H "Content-Type: application/json" \ | ||
-d "$BODY" \ | ||
https://circleci.com/api/v2/project/github/cypress-io/cypress-publish-binary/pipeline | ||
|
||
if [[ $? != 0 ]]; then | ||
echo "Failed to trigger new pipeline. Skipping pipeline trigger." | ||
exit 1 | ||
fi | ||
|
||
echo "Pipeline saved to triggered_pipeline.json" | ||
echo "Triggered pipeline: https://app.circleci.com/pipelines/github/cypress-io/cypress-publish-binary/$(jq -r '.number' triggered_pipeline.json)" | ||
- persist_to_workspace: | ||
root: ~/ | ||
paths: | ||
- triggered_pipeline.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be parameterized as well (separately, to reduce delta surface)