forked from alibaba/ROCK
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (53 loc) · 2.27 KB
/
docs-request-trigger.yml
File metadata and controls
59 lines (53 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This is a basic workflow to help you get started with Actions
name: Docs Request Trigger
# Controls when the workflow will run
on:
pull_request:
branches: [ "master" ]
paths:
- '.github/workflows/docs-request-trigger.yml'
- 'docs/**'
types: [closed]
# 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:
if: github.event_name != 'pull_request' || github.event.pull_request.merged == true
# 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-docs.sh
- name: trigger a CI
run: |
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"
# Extract PR ID correctly for different scenarios
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# For pull_request events, we can use the event payload
PR_ID="${{ github.event.pull_request.number }}"
else
# Try to extract PR ID from GITHUB_REF if it's in PR format
if [[ "$GITHUB_REF" =~ refs/pull/([0-9]+)/ ]]; then
PR_ID="${BASH_REMATCH[1]}"
else
# Generate a random value when no PR ID is found
PR_ID="random-$(date +%s)-$$"
fi
fi
echo "PR ID is $PR_ID"
./trigger-docs.sh "$COMMIT_ID" "${{ secrets.CI_SECRET }}" "${{ github.event.pull_request.head.repo.clone_url }}" "$PR_ID" "${{ secrets.CHECK_USER_NAME }}" "${{ secrets.CHECK_TOKEN }}"