damccorm commented on code in PR #27210:
URL: https://github.com/apache/beam/pull/27210#discussion_r1237382199


##########
.github/actions/rerun-job-action/action.yml:
##########
@@ -0,0 +1,135 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+name: "Rerun Job Action"
+description: Re-runs a job that is attached to the PR as Check Run
+inputs:
+  pull_request_url:
+    description: "The URL of the PR"
+    required: true
+  github_repository:
+    description: "The GitHub repository"
+    required: true
+  github_token:
+    description: "The GitHub token"
+    required: true
+  github_job:
+    description: "The GitHub job"
+    required: true
+  github_current_run_id:
+    description: "The GitHub current run id. Not the same that is fetched in 
this action"
+    required: true
+
+
+runs:
+  using: composite
+  steps:
+  - name: Get Last Commit SHA
+    shell: bash
+    run: | 
+      URL=${{inputs.pull_request_url}}/commits
+      PRSHA=$(curl  \
+      -H 'Authorization: Bearer ${{inputs.github_token}}' \
+      -H "Accept: application/vnd.github+json" \
+      -H "X-GitHub-Api-Version: 2022-11-28" \
+      -s $URL  | jq -r '.[-1].sha' ) 
+      echo prsha=$PRSHA >> $GITHUB_ENV
+
+  - name: Get Status for PR Job
+    id: get_status
+    shell: bash
+    run: | 
+      
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+      STATUS=$(curl  \
+      -H 'Authorization: Bearer ${{inputs.github_token}}' \
+      -H "Accept: application/vnd.github+json" \
+      -H "X-GitHub-Api-Version: 2022-11-28" \
+      -s $URL | jq -r '.check_runs | .[] | 
select(.name=="${{inputs.github_job}}") | .status')
+      echo status=$STATUS >> $GITHUB_ENV    
+
+  - name: Get Conclusion for PR Job
+    id: get_conclusion
+    shell: bash
+    run: | 
+      
URL="${{github.api_url}}/repos/${{inputs.github_repository}}/commits/${{env.prsha}}/check-runs"
+      CONCLUSION=$(curl  \
+      -H 'Authorization: Bearer ${{inputs.github_token}}' \
+      -H "Accept: application/vnd.github+json" \
+      -H "X-GitHub-Api-Version: 2022-11-28" \
+      -s $URL | jq -r '.check_runs | .[] | 
select(.name=="${{inputs.github_job}}") | .conclusion')
+      echo conclusion=$CONCLUSION >> $GITHUB_ENV
+  
+  # If a success or skip job is detected the logic will not excecute, job will 
not be re-run as its not needed

Review Comment:
   ```suggestion
     # If a success or skip job is detected the logic will not execute, job 
will not be re-run.
     # Instead, a new instance of the job will be started instead of exiting 
early.
     # This won't status in the PR but can be found in the actions tab: 
https://github.com/apache/beam/actions
   ```
   
   I think being really explicit here will be helpful since most people who 
read this probably won't have a high familiarity with how actions work.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to