on:
  pull_request:
    branches:
      - staging
    types:
      - closed

jobs:
  create_pull_request_to_production:
    runs-on: ubuntu-latest
    if: github.event.pull_request.merged
    steps:
      - uses: actions/github-script@0.8.0
        with:
          script: |
            const staging_pull_request = context.payload.pull_request
            const production_pull_request = await github.pulls.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: staging_pull_request.title.replace(/deploy to staging/i, 'Deploy to Production'),
              head: context.ref,
              base: 'master',
              body: staging_pull_request.body
            })
            console.log(production_pull_request)
            github.pulls.createReviewRequest({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: production_pull_request.number,
              reviewers: ['aprice14']
            })
            github.issues.addAssignees({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: production_pull_request.number,
              assignees: staging_pull_request.assignees
            })

on:
  pull_request:
    branches:
      - staging
    types:
      - closed

jobs:
  create_pull_request_to_production:
    runs-on: ubuntu-latest
    if: github.event.pull_request.merged
    steps:
      - uses: actions/github-script@0.8.0
        with:
          script: |
            const staging_pull_request = context.payload.pull_request
            const { data: production_pull_request } = await github.pulls.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: staging_pull_request.title.replace(/deploy to staging/i, 'Deploy to Production'),
              head: context.ref,
              base: 'master',
              body: staging_pull_request.body
            })
            console.log(production_pull_request)
            const response = github.pulls.createReviewRequest({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: production_pull_request.number,
              reviewers: ['aprice14']
            })
            console.log(response)
            github.issues.addAssignees({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: production_pull_request.number,
              assignees: staging_pull_request.assignees
            })

Fix getting response of created pull request.
workflow: Fix getting response of created pull request.
