test: debug #18
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
| name: Deploy TDengine Cluster | |
| on: | |
| push: | |
| branches: | |
| - test/fractal | |
| # on: | |
| # workflow_dispatch: | |
| # inputs: | |
| # version: | |
| # description: 'Enter the version of TDengine to install' | |
| # required: true | |
| # default: '3.3.5.1' | |
| # group: | |
| # description: 'Enter the group for the runner' | |
| # required: true | |
| # default: 'default' | |
| # dnode_count: | |
| # description: 'Number of nodes to deploy' | |
| # required: true | |
| # default: '2' | |
| permissions: | |
| actions: read | |
| contents: read | |
| jobs: | |
| filter-runners: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| runners: ${{ steps.get-runners.outputs.runners }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Get Available Runners | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RUNNER_PAT }} | |
| id: get-runners | |
| run: | | |
| set -euo pipefail | |
| echo "Fetching available runners..." | |
| response_file=$(mktemp) | |
| gh api /orgs/${{ github.repository_owner }}/actions/runners \ | |
| --paginate \ | |
| --jq '.runners' > "$response_file" | |
| # 设置 dnode_count 的值 | |
| dnode_count=2 | |
| # 过滤并格式化 runners | |
| filtered_runners=$(jq -c --argjson count "$dnode_count" ' | |
| map( | |
| select( | |
| .labels | | |
| (map(.name) | index("fractal")) != null and | |
| (map(.name) | index("edge_td")) != null | |
| ) | |
| | { | |
| name, | |
| labels: ( | |
| .labels | map(.name) | join(", ") | | |
| split(", ") | | |
| map(select(. != "")) | | |
| ["self-hosted", "Linux", "X64"] + . | |
| ) | |
| } | |
| )[:$count]' "$response_file") | |
| echo "✅ Selected runners with formatted labels:" | |
| echo "$filtered_runners" | |
| update-hosts: | |
| needs: filter-runners | |
| runs-on: | |
| group: fractal | |
| labels: ${{ matrix.labels }} | |
| strategy: | |
| matrix: ${{ fromJson(needs.filter-runners.outputs.matrix) }} | |
| steps: | |
| - name: Print Runner Info | |
| run: | | |
| echo "🔄 Running on group: ${{ matrix.group }}" | |
| echo "🔄 Labels: ${{ matrix.labels }}" | |
| - name: Get IP and Hostname | |
| run: | | |
| echo "🔄 Getting IP and hostname for the runner..." | |
| # 假设通过某种方式获取 IP 和主机名 | |
| ip="192.168.1.100" # 替换为实际获取 IP 的逻辑 | |
| hostname="runner.example.com" # 替换为实际获取主机名的逻辑 | |
| echo "IP: $ip" | |
| echo "Hostname: $hostname" | |
| # 将 IP 和主机名写入 /etc/hosts | |
| echo "$ip $hostname" | sudo tee -a /etc/hosts | |
| echo "✅ Updated /etc/hosts with runner IP and hostname:" | |
| cat /etc/hosts | |
| # response_file=$(mktemp) | |
| # if ! gh api "/orgs/${{ github.repository_owner }}/actions/runners" \ | |
| # --method GET \ | |
| # --paginate \ | |
| # --jq '.runners' > "$response_file"; | |
| # then | |
| # echo "❌ Failed to fetch runners" | |
| # exit 1 | |
| # fi | |
| # # 验证响应内容 | |
| # if [ ! -s "$response_file" ]; then | |
| # echo "⚠️ Empty API response" | |
| # exit 1 | |
| # fi | |
| # # 处理JSON数据 | |
| # filtered_runners=$(jq -c ' | |
| # map( | |
| # select( | |
| # .labels | | |
| # (map(.name) | | |
| # contains(["fractal"]) and | |
| # contains(["edge_td"]) | |
| # ) | |
| # ) | |
| # | {name, labels} | |
| # )' "$response_file") | |
| # # 验证JSON有效性 | |
| # if ! jq -e . >/dev/null 2>&1 <<< "$filtered_runners"; then | |
| # echo "❌ Invalid JSON output" | |
| # exit 1 | |
| # fi | |
| # echo "✅ Filtered runners:" | |
| # jq . <<< "$filtered_runners" | |
| # # 使用JSON格式输出 | |
| # echo "runners=$filtered_runners" >> $GITHUB_OUTPUT | |
| # call-install: | |
| # runs-on: | |
| # group: ${{ github.event.inputs.group }} | |
| # labels: ${{ fromJson(github.event.inputs.labels) }} | |
| # steps: | |
| # - name: Check and Install TDengine Enterprise | |
| # uses: taosdata/.github/.github/actions/install-tdengine@test/fractal | |
| # with: | |
| # version: ${{ github.event.inputs.version }} | |
| # group: ${{ github.event.inputs.group }} | |
| # labels: ${{ github.event.inputs.labels }} | |
| # NAS_DOWNLOAD_URL: ${{ secrets.NAS_DOWNLOAD_URL }} |