deploy fractal environment #89
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 fractal environment | |
on: | |
workflow_dispatch: | |
inputs: | |
runner_number: | |
description: 'Runner number (1-2)' | |
required: true | |
type: choice | |
options: | |
- 1 | |
- 2 | |
version: | |
description: 'Enter the version of TDengine to install' | |
required: true | |
default: '3.3.5.1' | |
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 | |
- name: Setup labels | |
id: setup-labels | |
run: | | |
labels="[self-hosted, Linux, X64, fractal, edge_td,${{ matrix.combination.fractal_edge }}]" | |
echo "fractal_edge_labels=$labels" >> $GITHUB_ENV | |
- name: Check and Install TDengine Enterprise | |
uses: taosdata/.github/.github/actions/install-tdengine-enterprise@fractal | |
with: | |
version: ${{ github.event.inputs.version }} | |
group: fractal | |
labels: ${{steps.setup-labels.outputs.fractal_edge_labels}} | |
NAS_DOWNLOAD_URL: ${{ secrets.NAS_DOWNLOAD_URL }} | |
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: Install flashmq | |
uses: taosdata/.github/.github/actions/install-flashmq@fractal | |
- 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.RES_APP_ID }} | |
res_app_key: ${{ secrets.RES_APP_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 | |
- 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 | |