Closed adrianjost closed 4 years ago
I think process.env.GITHUB_HEAD_REF
does this as well -- does that work for you?
Maybe. I will check that! Thanks for the hint :)
I need this too so I can auto deploy pull requests. Tried using ${{ github.event.pull_request.head.sha }} but is not there...
If you could expode the PR last sha or at least the branch name would be awesome!
I managed to get pr information by querying the github api
- name: GitHub API Request
id: request
if: steps.check.outputs.triggered == 'true'
uses: octokit/request-action@v2.0.0
with:
route: ${{ github.event.issue.pull_request.url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR informations
if: steps.check.outputs.triggered == 'true'
id: pr_data
run: |
echo "::set-output name=branch::${{ fromJson(steps.request.outputs.data).head.ref }}"
echo "::set-output name=repo_name::${{ fromJson(steps.request.outputs.data).base.repo.full_name }}"
echo "::set-output name=repo_clone_url::${{ fromJson(steps.request.outputs.data).base.repo.clone_url }}"
echo "::set-output name=repo_ssh_url::${{ fromJson(steps.request.outputs.data).base.repo.ssh_url }}"
Hope this can help 😉
@paulhenri-l that seems to work. Thank you!
For a working example, check https://github.com/adrianjost/workflow-trigger-comment-example/pull/3 and https://github.com/adrianjost/workflow-trigger-comment-example/blob/master/.github/workflows/demo.yml
Your example really helped @adrianjost specially the GitHub API Request
part. Thanks (:
It would be realy helpfull if this plugin also outputs the head ref of the PR, so you can chain actions that do something with the PR.
My current use-case is, that I wan't to run a command that changes some files and commit them to the PR, whenever a given command is commented on the PR.
As far as I can see, the
@github/actions
package already provides you the information I need, you only need to expose them usingsetOutput
.Ressources: