title: What is a predictable commit sha to use when merging pull request to a master using GitHub actions?
body: <p>I am using [github-actions]. I have two worksflows:</p>
  <ul>
  <li>triggered on <code>pull_request</code></li>
  <li>triggered on <code>push</code></li>
  </ul>
  <pre class="lang-yaml prettyprint-override"><code>on:
    workflow_dispatch:
    pull_request:
      branches:
        - master
  </code></pre>
  <pre class="lang-yaml prettyprint-override"><code>on:
    workflow_dispatch:
    push:
      branches:
        - master
  </code></pre>
  <p>The <code>pull_request</code> workflow generates assets that need be used in <code>push</code> workflow. I need some sort of an identifier that would allow me to connect the two workflows, ideally SHA of git merge commit. However, I was not able to identify a reliable reference to use.</p>
  <p>At the moment I am using <code>${{ github.event.pull_request.head.sha }}</code> in <code>pull_request</code> workflow, and in <code>push</code> workflow I am using:</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: Setup repository
    uses: actions/checkout@v2
    with:
      fetch-depth: 2
  - name: Set CI_COMMIT_SHORT_SHA env property
    shell: bash
    run: echo &quot;CI_COMMIT_SHORT_SHA=$(git rev-parse --short=8 HEAD^2)&quot; &gt;&gt; $GITHUB_ENV
  </code></pre>
  <p>This works most of the time but breaks when commits are force pushed to the PR branch before it is merged.</p>
  <p>What is a reliable <a href="/questions/tagged/git" class="post-tag" title="show questions tagged &#39;git&#39;" rel="tag">git</a> reference to associate <code>pull_request</code> with <code>push</code> workflows?</p>