2020
2121 secrets :
2222 DEVHUB_APP_ID :
23- required : true
23+ required : false
2424 DEVHUB_APP_PRIVATE_KEY :
25- required : true
25+ required : false
2626
2727jobs :
2828 pr-handler :
2929 runs-on : ubuntu-latest
3030 if : github.event.pull_request != null
31+
3132 steps :
32- - name : Checkout base branch only
33+ - name : Checkout base branch
3334 uses : actions/checkout@v5
3435 with :
3536 ref : ${{ github.event.pull_request.base.ref }}
3637 fetch-depth : 0
3738 persist-credentials : false
3839
3940 - name : Generate DevHub Bot token
41+ if : ${{ secrets.DEVHUB_APP_ID && secrets.DEVHUB_APP_PRIVATE_KEY }}
4042 id : app-token
4143 uses : actions/create-github-app-token@v1
4244 with :
4345 app-id : ${{ secrets.DEVHUB_APP_ID }}
4446 private-key : ${{ secrets.DEVHUB_APP_PRIVATE_KEY }}
4547
46- - name : Fetch all PR commits via API
48+ - name : Fetch PR commits
4749 id : commits
4850 uses : actions/github-script@v7
4951 with :
50- github-token : ${{ steps.app-token.outputs.token }}
52+ github-token : ${{ steps.app-token.outputs.token || github.token }}
5153 script : |
5254 const commits = await github.paginate(
5355 github.rest.pulls.listCommits,
5961 );
6062 core.setOutput("messages", JSON.stringify(commits.map(c => c.commit.message)));
6163
62- - name : Check Conventional Commits
64+ - name : Check CC compliance
6365 id : analyze
6466 run : |
6567 echo '${{ steps.commits.outputs.messages }}' > commits.json
@@ -76,12 +78,13 @@ jobs:
7678
7779 echo "non_cc=$NON_CC" >> $GITHUB_OUTPUT
7880
79- - name : Comment as bot
81+ - name : Comment PR
8082 uses : actions/github-script@v7
8183 with :
82- github-token : ${{ steps.app-token.outputs.token }}
84+ github-token : ${{ steps.app-token.outputs.token || github.token }}
8385 script : |
84- const body = "${{ steps.analyze.outputs.non_cc }}" === "true"
86+ const nonCC = "${{ steps.analyze.outputs.non_cc }}" === "true";
87+ const body = nonCC
8588 ? `${{ inputs.cc_warning_message }}`
8689 : `${{ inputs.thank_you_message }}`;
8790
@@ -101,16 +104,17 @@ jobs:
101104 ref : ${{ github.event.pull_request.base.ref }}
102105
103106 - name : Generate DevHub Bot token
107+ if : ${{ secrets.DEVHUB_APP_ID && secrets.DEVHUB_APP_PRIVATE_KEY }}
104108 id : app-token
105109 uses : actions/create-github-app-token@v1
106110 with :
107111 app-id : ${{ secrets.DEVHUB_APP_ID }}
108112 private-key : ${{ secrets.DEVHUB_APP_PRIVATE_KEY }}
109113
110- - name : Thank contributor as bot
114+ - name : Thank contributor
111115 uses : actions/github-script@v7
112116 with :
113- github-token : ${{ steps.app-token.outputs.token }}
117+ github-token : ${{ steps.app-token.outputs.token || github.token }}
114118 script : |
115119 await github.rest.issues.createComment({
116120 owner: context.repo.owner,
@@ -124,6 +128,7 @@ jobs:
124128 if : github.event_name == 'issues' && github.event.action == 'opened'
125129 steps :
126130 - name : Generate DevHub Bot token
131+ if : ${{ secrets.DEVHUB_APP_ID && secrets.DEVHUB_APP_PRIVATE_KEY }}
127132 id : app-token
128133 uses : actions/create-github-app-token@v1
129134 with :
@@ -133,10 +138,9 @@ jobs:
133138 - name : Handle issue open (labels + comment)
134139 uses : actions/github-script@v7
135140 with :
136- github-token : ${{ steps.app-token.outputs.token }}
141+ github-token : ${{ steps.app-token.outputs.token || github.token }}
137142 script : |
138143 const issue = context.payload.issue;
139-
140144 const text = `${issue.title}\n${issue.body ?? ""}`.toLowerCase();
141145
142146 const rules = [
0 commit comments