5656 runs-on : ubuntu-latest
5757 outputs :
5858 cmd : ${{ steps.parse-cmd.outputs.cmd }}
59- replyMessage : ${{ steps.parse-cmd.outputs.replyMessage }}
6059 pullRequestJSON : ${{ steps.parse-cmd.outputs.pullRequestJSON }}
6160 steps :
6261 - uses : actions/github-script@v5
@@ -103,26 +102,42 @@ jobs:
103102 if : needs.accept-cmd.result != 'skipped' && always()
104103 runs-on : ubuntu-latest
105104 steps :
106- - uses : actions/github-script@v5
105+ - uses : actions/download-artifact@v2
106+ with :
107+ name : replyMessage
108+
109+ - if : failure()
110+ uses : actions/github-script@v5
107111 with :
108112 script : |
109- const { issue, comment, sender } = context.payload;
113+ const fs = require('fs');
114+
110115 const needs = JSON.parse(process.env.NEEDS);
111116
112- let replyMessage;
113117 let allSkipped = true;
114118 for (const [ name, job ] of Object.entries(needs)) {
115119 if (name.startsWith('cmd-')) {
116120 allSkipped = allSkipped && job.result === 'skipped';
117121 }
118- replyMessage = replyMessage || job.outputs.replyMessage;
119122 }
120123
121- if (!replyMessage) {
122- replyMessage = allSkipped
123- ? 'Unknown command 😕\n\n' + process.env.SUPPORTED_COMMANDS
124- : `Something went wrong, [please check log](${process.env.RUN_URL}).`;
125- }
124+ const replyMessage = allSkipped
125+ ? 'Unknown command 😕\n\n' + process.env.SUPPORTED_COMMANDS
126+ : `Something went wrong, [please check log](${process.env.RUN_URL}).`;
127+
128+ fs.writeFileSync('./replyMessage.txt', replyMessage, 'utf-8');
129+ env :
130+ NEEDS : ${{ toJSON(needs) }}
131+ RUN_URL : ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}
132+
133+ - if : always()
134+ uses : actions/github-script@v5
135+ with :
136+ script : |
137+ const fs = require('fs');
138+
139+ const replyMessage = fs.readFileSync('./replyMessage.txt', 'utf-8');
140+ const { issue, comment, sender } = context.payload;
126141
127142 const quoteRequest = comment.body
128143 .split('\n')
@@ -142,6 +157,3 @@ jobs:
142157 { __typename }
143158 }
144159 `, { subjectId: comment.node_id });
145- env :
146- RUN_URL : ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}
147- NEEDS : ${{ toJSON(needs) }}
0 commit comments