I have Jenkins pipeline code which will check, if pull request is approved or not. If its not approved it will wait till the pull request approve. So I want to add same step in github actions since we are migrating from Jenkins pipeline.
I have tried adding in GitHub actions but getting some error. Any suggestion would be great.
** stage('PR status') {
steps {
script{
withCredentials([usernamePassword(credentialsId: 'test', passwordVariable: 'PASSWORD_PR_COMMENT', usernameVariable: 'USERNAME_PR_COMMENT')]) {
defPULL_REQUEST = env.ghprbPullId
while ({
cmd = "curl -X GET -H \'Authorization: token ${PASSWORD_PR_COMMENT}\' \'https://github.org/api/v3/repos/data/k/pulls/${PULL_REQUEST}/reviews\' | jq '.[0].state'"
REQUEST_STATUS= sh(script:cmd, returnStdout: true).trim()
print(REQUEST_STATUS)
sleep('time': 3600,'unit':"SECONDS")
["APPROVED","REJECTED","DISMISSED","null"].contains(REQUEST_STATUS)
}()) continue
}
}
}}