deploy fractal environment #83
This file contains 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
name: deploy-mqttcli | |
on: | |
workflow_dispatch: | |
inputs: | |
runner_number: | |
description: 'Runner number (1-2)' | |
required: true | |
type: choice | |
options: | |
- 1 | |
- 2 | |
jobs: | |
set-runners: | |
runs-on: ubuntu-latest | |
outputs: | |
runner_combinations: ${{ steps.set-runner-combinations.outputs.runner_combinations }} | |
steps: | |
- name: Set Runner Combinations | |
id: set-runner-combinations | |
run: | | |
echo "Setting Runner Combinations" | |
# 生成 mqtt-client 和 fractal-edge 的标签数组 | |
mqtt_client=$(seq 1 2 | sed 's/^/mqtt-client/') | |
fractal_edge=$(seq 1 2 | sed 's/^/fractal-edge-/') | |
mqtt_json=$(echo "$mqtt_client" | jq -R -s -c 'split("\n")[:-1]') # 去除末尾空元素 | |
fractal_json=$(echo "$fractal_edge" | jq -R -s -c 'split("\n")[:-1]') | |
combinations=$(jq -n --argjson a "$mqtt_json" --argjson b "$fractal_json" '$a | to_entries | map({ mqtt_client: .value, fractal_edge: $b[.key] })'| jq -c .) | |
echo "Generated combinations: $combinations" | |
echo "::set-output name=runner_combinations::$combinations" | |
deploy-fractal-edge: | |
needs: set-runners | |
strategy: | |
matrix: | |
combination: ${{ fromJSON(needs.set-runners.outputs.runner_combinations) }} | |
runs-on: | |
group: fractal | |
labels: | |
- self-hosted | |
- Linux | |
- X64 | |
- edge_td | |
- fractal | |
- ${{ matrix.combination.fractal_edge }} | |
outputs: | |
fractal_ip: ${{ steps.get-ip.outputs.local_ip }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get IP Addresses | |
id: get-ip | |
run: | | |
local_ip=$(hostname -I | awk '{print $1}') | |
echo "Local IP Address: $local_ip" | |
echo "$local_ip" > ${{ matrix.combination.fractal_edge }}.txt | |
- name: Upload IP Address as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.combination.fractal_edge }}-ip | |
path: ${{ matrix.combination.fractal_edge }}.txt | |
deploy-mqtt-client: | |
needs: [set-runners,deploy-fractal-edge] | |
strategy: | |
matrix: | |
combination: ${{ fromJSON(needs.set-runners.outputs.runner_combinations) }} | |
runs-on: | |
group: fractal | |
labels: | |
- self-hosted | |
- Linux | |
- X64 | |
- fractal | |
- ${{ matrix.combination.mqtt_client }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download IP Address Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.combination.fractal_edge }}-ip | |
path: ./ip_artifacts | |
- name: Use Fractal Edges IPs | |
run: | | |
fractal_ip=$(cat ./ip_artifacts/${{ matrix.combination.fractal_edge }}.txt) | |
echo "Fractal IPs: $fractal_ip" | |
echo "FRACTAL_IP=$fractal_ip" >> $GITHUB_ENV | |
- name: Replace Sources | |
run: | | |
cd /root/tools/deploy && ./setup_system.sh replace_sources | |
- name: Install MQTT CLI | |
uses: taosdata/.github/.github/actions/install-mqtt-simulator@fractal | |
with: | |
res_app_id: ${{ vars.TAOSDATA_BOT_ID }} | |
res_app_key: ${{ secrets.TAOSDATA_BOT_KEY }} | |
- name: Find mqtt_pub binary | |
run: | | |
if command -v mqtt_pub &> /dev/null; then | |
echo "mqtt_pub found at $(command -v mqtt_pub)" | |
else | |
echo "mqtt_pub not found" | |
fi | |