deployments icon indicating copy to clipboard operation
deployments copied to clipboard

Deployment status in PR not starting or updating

Open alipas opened this issue 2 years ago • 5 comments

I'm not quite sure what is causing this as this configuration has worked before. There's nothing particularly complicated about it and looks similar to the examples given here.

To add to the mystery, the deployment can be seen under Deployments/History but the PR deployment status is stuck in This branch has not been deployed.

Steps are as follows and job throws no warnings or errors.

Start

    - name: Start
      uses: bobheadxi/deployments@v1
      id: status
      with:
        step: start
        token: ${{ secrets.GITHUB_TOKEN }}
        env: staging

Debug output:

targeting ***/***
'start' arguments {
  stepArgs: { deploymentID: '', override: false, payload: undefined },
  coreArgs: {
    environment: 'staging',
    description: '',
    logsURL: 'https://github.com/***/***/commit/***/checks'
  }
}
initializing new deployment for staging @ refs/pull/10/merge
created deployment 783773500 for staging @ refs/pull/10/merge
created deployment status 1627565500 with status "in_progress"

Finish

    - name: Finish
      uses: bobheadxi/deployments@v1
      with:
        step: finish
        override: false
        auto_inactive: false
        token: ${{ secrets.GITHUB_TOKEN }}
        status: ${{ job.status }}
        env: ${{ steps.status.outputs.env }}
        deployment_id: ${{ steps.status.outputs.deployment_id }}
        env_url: ***

Debug output:

Run bobheadxi/deployments@v1
  with:
    step: finish
    override: false
    auto_inactive: false
    token: ***
    status: success
    env: staging
    deployment_id: 783773500
    env_url: ***
    debug: true
  env:
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    BRANCH: testbranch
targeting ***/***
'finish' arguments {
  stepArgs: {
    status: 'success',
    deploymentID: '783773500',
    envURL: '***',
    override: false,
    autoInactive: false
  },
finishing deployment for 783773500 with status success
  coreArgs: {
    environment: 'staging',
    description: '',
    logsURL: 'https://github.com/***/***/commit/***/checks'
  }
}
783773500 status set to success { statusID: 1627565500 }

alipas avatar Jan 31 '23 16:01 alipas

This looks like a quirk of GitHub PR ref. The PR ref is a "magical" merge ref, not a real branch and GitHub's deployment API doesn't appear to special case this. TL;DR: This action needs to use head_ref if it's available over context.ref.

RichiCoder1 avatar Feb 02 '23 23:02 RichiCoder1

Looks like that was the problem. Thanks a lot.

alipas avatar Feb 07 '23 16:02 alipas

Hey @alipas could you maybe elaborate a bit more on how you resolved this issue? Thx 🙏

wagnertimo avatar Mar 10 '23 10:03 wagnertimo

@wagnertimo Passing in the head_ref like this worked for me:

- name: Start GitHub deployment
  uses: bobheadxi/[email protected]
  id: deployment
  with:
    env: release
    ref: ${{ github.head_ref }}
    step: start
    token: ${{ secrets.GITHUB_TOKEN }}

psirenny avatar Mar 10 '23 13:03 psirenny

^ This. For ref: with both push and pull_request, you can do ${{ github.ref || github.head_ref }} to handle both variations.

RichiCoder1 avatar Mar 10 '23 18:03 RichiCoder1