diff --git a/.github/scripts/get-CI-result.sh b/.github/scripts/get-CI-result.sh index 19ee8a0c0..6c5eaf301 100644 --- a/.github/scripts/get-CI-result.sh +++ b/.github/scripts/get-CI-result.sh @@ -9,6 +9,8 @@ fi COMMIT_ID=$1 SECURITY=$2 REPOSITORY=$3 +PIPELINE_ID="42305" +PROJECT_ID="3567319" # 设置最大等待时间 MAX_WAIT_TIME=7200 @@ -19,7 +21,7 @@ while true; do response=$(curl -s -H "Content-Type: application/json" \ -H "Authorization: Basic ${SECURITY}" \ - -d "{\"type\": \"RETRIEVE-TASK-STATUS\", \"repositoryUrl\": \"${REPOSITORY}\", \"commitId\": \"${COMMIT_ID}\"}" "http://get-tasend-back-twkvcdsbpj.cn-hangzhou.fcapp.run") + -d "{\"type\": \"RETRIEVE-TASK-STATUS\", \"aone\": { \"projectId\": \"${PROJECT_ID}\", \"pipelineId\": \"${PIPELINE_ID}\"}, \"repositoryUrl\": \"${REPOSITORY}\",\"commitId\": \"${COMMIT_ID}\"}" "http://get-tasend-back-twkvcdsbpj.cn-hangzhou.fcapp.run") echo "Response: $response" # 检查curl是否成功 diff --git a/.github/workflows/CI-request-trigger.yml b/.github/workflows/CI-request-trigger.yml new file mode 100644 index 000000000..cf51c3b4f --- /dev/null +++ b/.github/workflows/CI-request-trigger.yml @@ -0,0 +1,51 @@ +# This is a basic workflow to help you get started with Actions + +name: CI Request Trigger + +# Controls when the workflow will run +on: + pull_request: + branches: [ "master" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # work on CI script dir + defaults: + run: + working-directory: .github/scripts + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + # Runs trigger CI + - name: Make the script files executable + run: chmod +x trigger-CI.sh get-CI-result.sh + - name: trigger a CI + run: | + echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ===" + COMMIT_ID=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.event.pull_request.head.sha }}" || echo "${{ github.sha }}") + echo "Using Commit ID: $COMMIT_ID" + echo "$GITHUB_REF" + PR_ID=$(echo "$GITHUB_REF" | sed 's@refs/pull/\([0-9]\+\)/.*@\1@') + echo "PR ID is $PR_ID" + ./trigger-CI.sh "$COMMIT_ID" "${{ secrets.CI_SECRET }}" "${{ github.event.pull_request.head.repo.clone_url }}" "$PR_ID" + + # Runs get CI result + - name: Get CI result + run: | + echo "=== Task started at: $(date '+%Y-%m-%d %H:%M:%S') ===" + COMMIT_ID=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.event.pull_request.head.sha }}" || echo "${{ github.sha }}") + echo "Using Commit ID: $COMMIT_ID" + ./get-CI-result.sh "$COMMIT_ID" "${{ secrets.CI_SECRET }}" "${{ github.repository }}" \ No newline at end of file