Code Monkey home page Code Monkey logo

Comments (6)

ericsciple avatar ericsciple commented on August 25, 2024 5

@luludan v2 happens to fix the issue you were hitting. V2 fetches the specific SHA rather than the ref.

This just works:

on:
  pull_request:
    branches:
    - master
    types: [opened, synchronize, closed]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

from checkout.

filipesilvaa avatar filipesilvaa commented on August 25, 2024 4

hi @luludan try to use another ref, by default, actions/checkout uses ${{ github.ref }} which referes to something like: refs/pull/#/merge

an example, referencing another ref:

- uses: actions/checkout@v1
  with:
    ref: refs/heads/${{ github.head_ref }} # it could be ${{ github.base_ref }} also

from checkout.

ericsciple avatar ericsciple commented on August 25, 2024 1

i'll play around with this, i think i might know a way.

if you have the on: syntax handy, please provide

from checkout.

filipesilvaa avatar filipesilvaa commented on August 25, 2024 1

hi @ericsciple thanks for your support,

here is a sample of .yml:

name: Build

on:
  pull_request:
    branches:
    - master
    types: [opened, synchronize, closed]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Git Checkout PR Ref
      if: github.event.action != 'closed'
      uses: actions/checkout@v1

    - name: Git Checkout Base Ref
      if: github.event.pull_request.merged == true
      uses: actions/checkout@v1
      with:
        ref: refs/heads/${{ github.base_ref }}

from checkout.

fezho avatar fezho commented on August 25, 2024 1

@ericsciple I got an issue when using goveralls, mattn/goveralls#150
And I think it's because checkout fetches the specific SHA rather than the ref, however goveralls gets the wrong sha:

	if os.Getenv("GITHUB_EVENT_NAME") == "pull_request" {
		ghPR := getGithubEvent()["pull_request"].(map[string]interface{})
		ghHead := ghPR["head"].(map[string]interface{})
		commitRef = ghHead["sha"].(string)
	}

This can be fixed by using ref: ${{ github.event.pull_request.head.sha }}, but i do not want to use it when push to master. Any advice to fix this issue?

from checkout.

Gopikrishna19 avatar Gopikrishna19 commented on August 25, 2024

@fezho you can add event check:

    steps:
      - uses: actions/checkout@v2
        name: Checkout PR
        if: github.event_name == 'pull_request'
        with:
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: actions/checkout@v2
        name: Checkout Branch
        if: github.event_name == 'push'

When in pull request
On PR

When in a branch
On Branch

from checkout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.