-
Notifications
You must be signed in to change notification settings - Fork 727
133 lines (127 loc) · 5.3 KB
/
pr-builder-test-JDK11.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: pr-builder-test
on:
workflow_dispatch:
inputs:
pr:
description: "Enter PR link (ex: https://github.com/wso2-extensions/identity-inbound-auth-oauth/pull/1481)"
default:
required: true
jdk:
description: "Enter Java version (ex: 8,11)"
default:
required: true
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Djdk.util.zip.disableZip64ExtraFieldValidation=true
jobs:
build:
runs-on: ubuntu-latest
env:
JAVA_TOOL_OPTIONS: "-Djdk.util.zip.disableZip64ExtraFieldValidation=true -Djdk.nio.zipfs.allowDotZipEntry=true"
steps:
- name: Print Input
run: echo Running the PR builder for PR - ${{ github.event.inputs.pr }}
- name: Comment build info
run: |
owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
curl -X POST https://api.github.com/repos/$owner/$repo/issues/$pr_number/comments -H 'Authorization: token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"PR builder started \nLink: https://github.com/wso2/product-is/actions/runs/${{github.run_id}}"}'
- uses: actions/checkout@v2
- name: Set up Adopt JDK 8
uses: actions/setup-java@v2
with:
java-version: "8"
distribution: "adopt"
- name: Echo java 8 home
run: |
echo "J8HOME=$JAVA_HOME" >> ${GITHUB_ENV}
id: java-8-setup
- name: Set up Adopt JDK 11
uses: actions/setup-java@v2
with:
java-version: "11"
distribution: "adopt"
- name: Echo java 11 home
run: |
echo "J11HOME=$JAVA_HOME" >> ${GITHUB_ENV}
- name: Build init
run: |
echo "CURRENT_MONTH=$(date +%Y-%m)" >> ${GITHUB_ENV}
- name: Cache maven packages
id: cache-maven-m2
uses: actions/cache@v2
with:
path: |
~/.m2
!~/.m2/repository/org/wso2/is/wso2is
key: ${{ runner.os }}-pr-builder-${{ env.CURRENT_MONTH }}
- name: Setup pnpm
id: setup-pnpm
uses: pnpm/[email protected]
with:
version: latest
run_install: false
- name: Run PR builder
id: builder_step
env:
PR_LINK: ${{github.event.inputs.pr}}
JDK_VERSION: ${{github.event.inputs.jdk}}
JAVA_8_HOME: ${{env.J8HOME}}
JAVA_11_HOME: ${{env.J11HOME}}
run: |
wget https://raw.githubusercontent.com/wso2/product-is/master/.github/scripts/pr-builder.sh
bash pr-builder.sh
- name: Archive PR diff file
if: always()
uses: actions/upload-artifact@v4
with:
name: repo-pr-diff
path: |
${{steps.builder_step.outputs.REPO_NAME}}/diff.diff
if-no-files-found: warn
- name: Archive repo mvn build log
if: always() && steps.builder_step.outputs.REPO_NAME != 'product-is'
uses: actions/upload-artifact@v4
with:
name: repo-mvn-build-log
path: |
${{steps.builder_step.outputs.REPO_NAME}}/mvn-build.log
if-no-files-found: warn
- name: Archive repo surefire reports
if: always() && steps.builder_step.outputs.REPO_NAME != 'product-is'
uses: actions/upload-artifact@v4
with:
name: repo-surefire-report
path: |
${{steps.builder_step.outputs.REPO_NAME}}/**/surefire-reports
if-no-files-found: warn
- name: Archive product-is mvn build log
if: always()
uses: actions/upload-artifact@v4
with:
name: product-is-mvn-build-log
path: |
product-is/mvn-build.log
if-no-files-found: warn
- name: Archive product-is surefire reports
if: always()
uses: actions/upload-artifact@v4
with:
name: product-is-surefire-report
path: |
product-is/**/surefire-reports
if-no-files-found: warn
- name: Comment build status
if: always()
run: |
owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
curl -X POST https://api.github.com/repos/$owner/$repo/issues/$pr_number/comments -H 'Authorization: token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"PR builder completed \nLink: https://github.com/wso2/product-is/actions/runs/${{github.run_id}} \nStatus: **${{job.status}}**"}'
- name: Approve PR
if: success()
run: |
owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
curl -X POST https://api.github.com/repos/$owner/$repo/pulls/$pr_number/reviews -H 'Authorization:token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/${{github.run_id}}","event":"APPROVE"}'