Release 11.0.0.17725
[platform/core/csapi/tizenfx.git] / .github / workflows / postback-pull-request.yml
1 name: "Postback Pull Request"
2
3 on:
4   workflow_run:
5     workflows: ["Build Pull Request"]
6     types:
7       - completed
8
9 jobs:
10   postback:
11     runs-on: ubuntu-20.04
12     steps:
13
14     - name: Download Artifacts from Build
15       uses: TizenAPI/tizenfx-build-actions/download-workflow-artifacts@master
16       with:
17         token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
18         run-id: ${{ github.event.workflow_run.id }}
19         name: reports
20         path: Artifacts
21
22     - name: Find Pull Request
23       id: pull_request
24       uses: actions/github-script@v2
25       env:
26         WORKFLOW_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
27       with:
28         script: |
29           const res = await github.pulls.list({
30             owner: context.repo.owner,
31             repo: context.repo.repo,
32             state: 'open'
33           });
34           if (res.status === 200) {
35             const pr = res.data.find(d => d.head.sha == process.env.WORKFLOW_HEAD_SHA);
36             if (pr) {
37               core.setOutput('number', pr.number);
38               core.setOutput('base_ref', pr.base.ref);
39             }
40           }
41
42     - name: Report Error if Failure
43       if: ${{ github.event.workflow_run.conclusion == 'failure' }}
44       uses: actions/github-script@v2
45       env:
46         PR_NUMBER: ${{ steps.pull_request.outputs.number }}
47       with:
48         github-token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
49         script: |
50           const fs = require('fs');
51           const json = fs.readFileSync('Artifacts/errors.json', 'utf8');
52           const errors = JSON.parse(json).join('\n');
53           github.issues.createComment({
54             issue_number: process.env.PR_NUMBER,
55             owner: context.repo.owner,
56             repo: context.repo.repo,
57             body: '## Build Error:\n```\n' + errors + '\n```'
58           });
59
60     - name: Report API comparison result
61       if: ${{ github.event.workflow_run.conclusion == 'success' }}
62       uses: TizenAPI/tizenfx-build-actions/apidb-report@master
63       with:
64         token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
65         issue-number: ${{ steps.pull_request.outputs.number }}
66         path: Artifacts/api-comp.json