andreydevyatkin commented on code in PR #27758:
URL: https://github.com/apache/beam/pull/27758#discussion_r1281152338


##########
.github/workflows/beam_PreCommit_Go.yml:
##########
@@ -37,17 +37,25 @@ concurrency:
 
 jobs:
   beam_PreCommit_Go:
+    name: beam_PreCommit_Go (Run Go PreCommit)
+    runs-on: [self-hosted, ubuntu-20.04, main]
     if: |
       github.event_name == 'push' ||
       github.event_name == 'pull_request_target' ||
       github.event_name == 'schedule' ||
+      github.event_name == 'workflow_dispatch' ||
       github.event.comment.body == 'Run Go PreCommit'
-    runs-on: [self-hosted, ubuntu-20.04, main]
-    name: beam_PreCommit_Go (Run Go PreCommit)
-    steps:       
-      - uses: actions/checkout@v3
+    steps:
+      - name: Check out repository code

Review Comment:
   @damccorm @Abacn It seems there is no concise way to encapsulate the 
checkout logic in a composite action. Based on the doc, we must checkout the 
repository before using the custom action 
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-an-action-in-the-same-repository-as-the-workflow.
 The only thing we can do is checkout the custom action code and use this 
action as the second step:
   ```
       steps:
         - name: Check out action code
           uses: actions/checkout@v3
           with:
             sparse-checkout: ./.github/actions/checkout
         - name: Check out repository code
           uses: ./.github/actions/checkout
           with:
             comment_phrase: 'Run Go PreCommit'
   ```
   Action:
   ```
   runs:
     using: composite
     steps:
       - name: Check out
         uses: actions/checkout@v3
         if: contains(fromJSON('["push", "pull_request_target", "schedule", 
"workflow_dispatch"]'), ${{ github.event_name }})
         with:
           ref: ${{ github.event.pull_request.head.sha }}
       - name: Check out if comment phrase
         uses: actions/checkout@v3
         if: ${{ github.event.comment.body }} == ${{ inputs.comment_phrase }}
         with:
           ref: refs/pull/${{ github.event.issue.number }}/head
   ```
   I think this approach adds more unclarity on how to properly use the action 
compared to the current implementation.



-- 
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