-
Notifications
You must be signed in to change notification settings - Fork 35
79 lines (69 loc) · 3.69 KB
/
iact3-test.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: iact3-test
on:
pull_request_target:
types: [ opened, synchronize, reopened ]
jobs:
iact3Test:
runs-on: ubuntu-latest
if: github.actor == github.event.pull_request.user.login
steps:
- name: White list
id: white-list
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
white_list=($(curl -sSL -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/${{ github.repository }}/collaborators" | jq -r '.[].login'))
echo $white_list
if [[ " ${white_list[@]} " =~ " ${{ github.actor }} " ]]; then
echo "type=test" >> $GITHUB_OUTPUT
else
echo "type=validate" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v3
id: checkout
with:
fetch-depth: 0
- name: Find changed templates
id: changed-templates
run: |
git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge
git checkout -qf FETCH_HEAD
echo "changed_files=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master) | xargs)" >> $GITHUB_OUTPUT
echo $(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master) | xargs)
- name: Test templates
uses: aliyun/alibabacloud-ros-tool-iact3@master
with:
templates: ${{ steps.changed-templates.outputs.changed_files }}
access_key_id: ${{ secrets.TEST_ACCOUNT_KEY }}
access_key_secret: ${{ secrets.TEST_ACCOUNT_SECRET }}
type: ${{ steps.white-list.outputs.type }}
id: test-templates
if: ${{ steps.white-list.outputs.type == 'test' }}
- name: Validate templates
uses: aliyun/alibabacloud-ros-tool-iact3@master
with:
templates: ${{ steps.changed-templates.outputs.changed_files }}
access_key_id: ${{ secrets.VALIDATE_ACCOUNT_KEY }}
access_key_secret: ${{ secrets.VALIDATE_ACCOUNT_SECRET }}
type: ${{ steps.white-list.outputs.type }}
id: validate-templates
if: ${{ steps.white-list.outputs.type == 'validate' }}
- name: DingTalk Robot
env:
TITLE: ${{ github.event.pull_request.title }}
if: always()
continue-on-error: true
run: |
if [[ "${{ steps.white-list.outputs.type }}" != "test" ]]; then
if [[ "${{ steps.validate-templates.outputs.status }}" = "success" ]]; then
curl -H 'Content-Type: application/json;charset=utf-8' -d '{"msgtype": "text","text": {"content": "Iact3-validate CI pass. ${{ github.event.pull_request.user.login }} PR#${{ github.event.pull_request.number }}:$TITLE ${{ github.event.pull_request.html_url }} "}}' ${{ secrets.DINGDING_WEBHOOK }}
else
curl -H 'Content-Type: application/json;charset=utf-8' -d '{"msgtype": "text","text": {"content": "Iact3-validate CI failed. ${{ github.event.pull_request.user.login }} PR#${{ github.event.pull_request.number }}:$TITLE ${{ github.event.pull_request.html_url }} "}}' ${{ secrets.DINGDING_WEBHOOK }}
fi
else
if [[ "${{ steps.test-templates.outputs.status }}" = "success" ]]; then
curl -H 'Content-Type: application/json;charset=utf-8' -d '{"msgtype": "text","text": {"content": "Iact3-test CI pass. ${{ github.event.pull_request.user.login }} PR#${{ github.event.pull_request.number }}:$TITLE ${{ github.event.pull_request.html_url }} "}}' ${{ secrets.DINGDING_WEBHOOK }}
else
curl -H 'Content-Type: application/json;charset=utf-8' -d '{"msgtype": "text","text": {"content": "Iact3-test CI failed. ${{ github.event.pull_request.user.login }} PR#${{ github.event.pull_request.number }}:$TITLE ${{ github.event.pull_request.html_url }} "}}' ${{ secrets.DINGDING_WEBHOOK }}
fi
fi