Skip to content

Commit

Permalink
test5
Browse files Browse the repository at this point in the history
  • Loading branch information
hulk510 committed Jan 17, 2024
1 parent 7c7b467 commit e7e91fd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
29 changes: 16 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 16 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,31 @@ export async function run(): Promise<void> {
try {
const token = core.getInput('repo-token')
const octokit = github.getOctokit(token)
// get context
// MEMO: git contextからheadRefは取得できなそう
const { repo, ref } = github.context
core.info(`ref: ${ref}`)
core.info(`payload: ${JSON.stringify(github.context.payload)}`)
core.info(
`number: ${JSON.stringify(github.context.payload.pull_request?.number)}`
)
core.info(
`head ref: ${JSON.stringify(
github.context.payload.pull_request?.head.ref
)}`
)

// const eventPath = process.env.GITHUB_EVENT_PATH
// get repostiory information
const { repo } = github.context

const headRef = process.env.GITHUB_HEAD_REF
core.info(`headRef: ${headRef}`)
const prNumber = github.context.payload.pull_request?.number
// MEMO: payloadから取得できるのは確認したけど、型何もついてない
const payload = github.context.payload
const prNumber = payload.pull_request?.number as number | undefined

Check failure on line 45 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

This assertion is unnecessary since it does not change the type of the expression

Check failure on line 45 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

This assertion is unnecessary since it does not change the type of the expression
const headRef = payload.pull_request?.head?.ref as string | undefined
const ref = payload.ref as string | undefined

if (prNumber) {
// fire when event is pull_request or pull_request_target or pull_request_review or pull_request_review_comment
core.info(`delete cache for refs/pull/${prNumber}/merge`)
deleteRefActionsCache(octokit, repo, `refs/pull/${prNumber}/merge`)
}
if (headRef) {
// fire when event is pull_request or pull_request_target or pull_request_review or pull_request_review_comment
core.info(`delete cache for refs/heads/${headRef}`)
deleteRefActionsCache(octokit, repo, `refs/heads/${headRef}`)
}
// workflow_dispatch or push
deleteRefActionsCache(octokit, repo, ref)
if (ref) {
// fire when event is workflow_dispatch or push
core.info(`delete cache for ${ref}`)
deleteRefActionsCache(octokit, repo, ref)
}
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
Expand Down

0 comments on commit e7e91fd

Please sign in to comment.