Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMath123 committed May 20, 2024
1 parent ccbd2e8 commit d365345
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions __tests__/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getInput, setFailed } from '@actions/core'
import { context as _context } from '@actions/github'
import { context as githubContext } from '@actions/github'
import { Octokit } from '@octokit/core'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
Expand Down Expand Up @@ -33,7 +33,13 @@ vi.mock('@actions/github', async importActual => {
return {
...actual,
context: {
ref: 'refs/heads/test-branch'
payload: {
pull_request: {
head: {
ref: 'test-branch'
}
}
}
}
}
})
Expand All @@ -48,8 +54,6 @@ describe('GitHub Action', () => {
}

Octokit.mockImplementation(() => octokitMock)

_context.ref = 'refs/heads/test-branch'
})

afterEach(() => {
Expand Down
5 changes: 2 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getInput, setFailed, setOutput } from '@actions/core'
import { context } from '@actions/github'
import { context as githubContext } from '@actions/github'
import { Octokit } from '@octokit/core'

export async function listDeployments(octokit, owner, repo) {
Expand Down Expand Up @@ -50,8 +50,7 @@ export async function run() {
const owner = getInput('owner', { required: true })
const repo = getInput('repo', { required: true })

const ref = context.ref
const branch = ref.replace('refs/heads/', '')
const branch = githubContext.payload.pull_request.head.ref

console.log(`Branch: ${branch}`)

Expand Down

0 comments on commit d365345

Please sign in to comment.