I tried the below workflow inorder to get the name of the approver for a strategy-matrix job.
Thus, i need to print <job-name> was approved by <approver-name>
for all the jobs for that particular run.
I’m facing couple of issues of which i will post and discuss one issue later which is to get approver-name while all the jobs are pararellely executed and approved before completion.
The other issue is that i m getting the below error when trying to get the job-nme and approver-name:
actions/github-script@v6
with:
github-token: ***
retries: 3
retry-exempt-status-codes: 400,401
script: const runId = "9061355293";
const repo = "DB_TESTPIPELINE";
const owner = "mybank";
const baseUri = "https://api.github.com/";
const endpoint = "approvals";
const envuri = '${baseUri}/repos/${owner}/${repo}/actions/runs/${runId}/${endpoint}';
const response = await github.request('GET', envuri);
const approvals = response.data;
const meapproval = approvals[0];
const environment = meapproval.environments[0];
const environmentName = environment.name;
const approverName = meapproval.user.login;
console.log(`Environment Name: ${environmentName}`);
console.log(`Approver Name: ${approverName}`);
// Set outputs
core.setOutput('environmentName', environmentName);
core.setOutput('approverName', approverName);
debug: false
user-agent: actions/github-script
result-encoding: json
env:
tokenkey: ***
AUTOMATEDTOKEN: ***
SQlPassword: ***
RequestError [HttpError]: request to https://api.github.comget/?0=%24&1=%7B&2=b&3=a&4=s&5=e&6=U&7=r&8=i&9=%7D&10=%2F&11=r&12=e&13=p&14=o&15=s&16=%2F&17=%24&18=%7B&19=o&20=w&21=n&22=e&23=r&24=%7D&25=%2F&26=%24&27=%7B&28=r&29=e&30=p&31=o&32=%7D&33=%2F&34=a&35=c&36=t&37=i&38=o&39=n&40=s&41=%2F&42=r&43=u&44=n&45=s&46=%2F&47=%24&48=%7B&49=r&50=u&51=n&52=I&53=d&54=%7D&55=%2F&56=%24&57=%7B&58=e&59=n&60=d&61=p&62=o&63=i&64=n&65=t&66=%7D failed, reason: getaddrinfo ENOTFOUND api.github.comget
at D:Git-RunnersGITHUB_WIN_RUNNER1-s9_work_actionsactionsgithub-scriptv6distindex.js:6864:11
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Job.doExecute (D:Git-RunnersGITHUB_WIN_RUNNER1-s9_work_actionsactionsgithub-scriptv6distindex.js:7588:18) {
status: 500,
request: {
method: 'GET',
url: 'https://api.github.comGET?0=%24&1=%7B&2=b&3=a&4=s&5=e&6=U&7=r&8=i&9=%7D&10=%2F&11=r&12=e&13=p&14=o&15=s&16=%2F&17=%24&18=%7B&19=o&20=w&21=n&22=e&23=r&24=%7D&25=%2F&26=%24&27=%7B&28=r&29=e&30=p&31=o&32=%7D&33=%2F&34=a&35=c&36=t&37=i&38=o&39=n&40=s&41=%2F&42=r&43=u&44=n&45=s&46=%2F&47=%24&48=%7B&49=r&50=u&51=n&52=I&53=d&54=%7D&55=%2F&56=%24&57=%7B&58=e&59=n&60=d&61=p&62=o&63=i&64=n&65=t&66=%7D',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'actions/github-script octokit-core.js/3.6.0 Node.js/16.20.2 (win32; x64)',
authorization: 'token [REDACTED]'
},
request: {
agent: [Agent],
retries: 3,
hook: [Function: bound bound register],
retryCount: 3,
retryAfter: 16
}
}
}
Error: Unhandled error: HttpError: request to https://api.github.comget/?0=%24&1=%7B&2=b&3=a&4=s&5=e&6=U&7=r&8=i&9=%7D&10=%2F&11=r&12=e&13=p&14=o&15=s&16=%2F&17=%24&18=%7B&19=o&20=w&21=n&22=e&23=r&24=%7D&25=%2F&26=%24&27=%7B&28=r&29=e&30=p&31=o&32=%7D&33=%2F&34=a&35=c&36=t&37=i&38=o&39=n&40=s&41=%2F&42=r&43=u&44=n&45=s&46=%2F&47=%24&48=%7B&49=r&50=u&51=n&52=I&53=d&54=%7D&55=%2F&56=%24&57=%7B&58=e&59=n&60=d&61=p&62=o&63=i&64=n&65=t&66=%7D failed, reason: getaddrinfo ENOTFOUND api.github.comget
Kindly suggest.