Created
January 17, 2023 23:07
-
-
Save jeffreyaven/bec7982143a9637f866b7239e8c18130 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as core from '@actions/core'; | |
import * as github from '@actions/github'; | |
import { exec } from 'node:child_process'; | |
async function run() { | |
try { | |
const context = github.context; | |
const eventName = context.eventName; | |
let prNumber; | |
if(eventName == 'pull_request') { | |
prNumber = context.payload.number; | |
} else if(eventName == 'push') { | |
const message = context.payload.head_commit.message.split('\n')[0]; | |
const commitMessageParts = message.split(' '); | |
prNumber = commitMessageParts[3].split('#')[1]; | |
} else { | |
core.setFailed(`Unsupported event: ${eventName}`); | |
return; | |
} | |
exec(`echo "REG_PR_NO=${prNumber}" >> $GITHUB_ENV`); | |
} catch (error) { | |
core.setFailed(error.message); | |
return; | |
} | |
} | |
await run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment