diff --git a/.yamato/_triggers.yml b/.yamato/_triggers.yml index 2c5498a3c..f0fe9e775 100644 --- a/.yamato/_triggers.yml +++ b/.yamato/_triggers.yml @@ -17,6 +17,7 @@ pull_request_trigger: # Android - .yamato/mobile-build-and-run.yml#mobile_test_android_{{ project.name }}_{{ project.test_editors.first }} {% endfor -%} + - .yamato/print_message_slack_channel.yml triggers: cancel_old_ci: true pull_requests: diff --git a/.yamato/print_message_slack_channel.py b/.yamato/print_message_slack_channel.py new file mode 100644 index 000000000..54bcbf8f4 --- /dev/null +++ b/.yamato/print_message_slack_channel.py @@ -0,0 +1,27 @@ +import requests +import json + +def send_slack_message(webhook_url, message): + # Define the payload to be sent to Slack + payload = { + "text": message + } + + # Convert the payload to JSON + payload_json = json.dumps(payload) + + # Send the HTTP POST request to Slack webhook URL + response = requests.post(webhook_url, data=payload_json) + + # Check if the request was successful + if response.status_code == 200: + print("Message sent successfully to Slack channel!") + else: + print(f"Failed to send message to Slack. Status code: {response.status_code}") + +# Set your Slack webhook URL and message +slack_webhook_url = "https://app.slack.com/client/E016WLPF0G6/C070FP6HJ2C?_gl=1*177f49f*_gcl_au*MTU2MTM4OTc3OC4xNzEzMTg3MTQx" +message_to_send = "Hello from Python script!" + +# Call the function to send the message +send_slack_message(slack_webhook_url, message_to_send) diff --git a/.yamato/print_message_slack_channel.yml b/.yamato/print_message_slack_channel.yml new file mode 100644 index 000000000..390841966 --- /dev/null +++ b/.yamato/print_message_slack_channel.yml @@ -0,0 +1,30 @@ +print_slack_message: + name: ⚡ Print Slack Message ⚡ + agent: + type: Unity::VM + image: package-ci/ubuntu:stable + flavor: b1.large + commands: + - command: |- + sudo apt install -y python3-pip + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo apt -y update + sudo apt -y install gh + timeout: 5 + retries: 5 + - command: pip install unity-downloader-cli --upgrade --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple + - command: npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - command: unity-downloader-cli -u trunk -c editor --wait --fast + - command: upm-ci package test -u .Editor --enable-code-coverage --code-coverage-options "generateAdditionalMetrics;generateHtmlReport;assemblyFilters:{% for assembly in code_coverage_assemblies -%}+{{ assembly }},{% endfor -%};" --extra-utr-arg=--coverage-results-path=$YAMATO_SOURCE_DIR/upm-ci~/test-results/CoverageResults + timeout: 5 + retries: 5 + - command: |- + echo # Print Slack Message + python .yamato/print_message_slack_channel.py + artifacts: + logs: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/package-pack.yml#pack \ No newline at end of file