Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 3c6ffa7

Browse files
committed
u
1 parent 58e2f29 commit 3c6ffa7

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

.github/actions/bytebase-cicd/dist/index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32458,7 +32458,7 @@ async function createRelease(migrationFiles) {
3245832458
files: files,
3245932459
vcsSource: {
3246032460
vcsType: 'GITHUB',
32461-
pullRequestUrl: ''
32461+
pullRequestUrl: (0, main_1.ctx)().commitUrl
3246232462
}
3246332463
});
3246432464
if (response.statusCode !== 200) {
@@ -32577,18 +32577,12 @@ const path = __importStar(__nccwpck_require__(6928));
3257732577
async function run() {
3257832578
try {
3257932579
const ghContext = github.context;
32580-
if (ghContext.eventName !== 'pull_request') {
32581-
throw new Error(`expect pull_request event, but get ${ghContext.eventName}`);
32580+
if (ghContext.eventName !== 'push') {
32581+
throw new Error(`expect push event, but get ${ghContext.eventName}`);
3258232582
}
32583-
const prPayload = ghContext.payload;
32584-
if (prPayload.action !== 'closed') {
32585-
throw new Error(`expect pull request was merged, get ${prPayload.action}`);
32586-
}
32587-
if (!prPayload.pull_request.merged) {
32588-
throw new Error('expect pull request was merged');
32589-
}
32590-
const commit = prPayload.pull_request.merge_commit_sha ?? 'unknown';
32591-
const prNumber = prPayload.pull_request.number;
32583+
const pushPayload = ghContext.payload;
32584+
const commit = pushPayload.after ?? 'unknown';
32585+
const commitUrl = pushPayload.head_commit?.url ?? '';
3259232586
const bbToken = core.getInput('bb-token', { required: true });
3259332587
const bbUrl = core.getInput('bb-url', { required: true });
3259432588
const bbProject = core.getInput('bb-project', { required: true });
@@ -32601,6 +32595,7 @@ async function run() {
3260132595
bbProject: bbProject,
3260232596
bbDatabase: bbDatabase,
3260332597
commit: commit,
32598+
commitUrl: commitUrl,
3260432599
c: new hc.HttpClient('bytebase-cicd-action', [], {
3260532600
headers: {
3260632601
authorization: `Bearer ${bbToken}`
@@ -32694,6 +32689,7 @@ let ctx = () => {
3269432689
bbProject: 'db333',
3269532690
bbDatabase: 'instances/dbdbdb/databases/db_1',
3269632691
commit: '',
32692+
commitUrl: '',
3269732693
c: new hc.HttpClient('bytebase-cicd-action', [], {
3269832694
headers: {
3269932695
authorization: `Bearer ${bbToken}`

.github/actions/bytebase-cicd/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/bytebase-cicd/src/bb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export async function createRelease(migrationFiles: MigrationFile[]) {
8383
files: files,
8484
vcsSource: {
8585
vcsType: 'GITHUB',
86-
pullRequestUrl: ''
86+
pullRequestUrl: ctx().commitUrl
8787
}
8888
})
8989

.github/actions/bytebase-cicd/src/main.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as glob from '@actions/glob'
1313
import * as github from '@actions/github'
1414
import * as fs from 'fs/promises'
1515
import * as path from 'path'
16-
import { PullRequestEvent } from '@octokit/webhooks-types'
16+
import { PushEvent, PullRequestEvent } from '@octokit/webhooks-types'
1717

1818
/**
1919
* The main function for the action.
@@ -23,21 +23,13 @@ export async function run(): Promise<void> {
2323
try {
2424
const ghContext = github.context
2525

26-
if (ghContext.eventName !== 'pull_request') {
27-
throw new Error(
28-
`expect pull_request event, but get ${ghContext.eventName}`
29-
)
30-
}
31-
const prPayload = ghContext.payload as PullRequestEvent
32-
if (prPayload.action !== 'closed') {
33-
throw new Error(`expect pull request was merged, get ${prPayload.action}`)
34-
}
35-
if (!prPayload.pull_request.merged) {
36-
throw new Error('expect pull request was merged')
26+
if (ghContext.eventName !== 'push') {
27+
throw new Error(`expect push event, but get ${ghContext.eventName}`)
3728
}
29+
const pushPayload = ghContext.payload as PushEvent
3830

39-
const commit = prPayload.pull_request.merge_commit_sha ?? 'unknown'
40-
const prNumber = prPayload.pull_request.number
31+
const commit = pushPayload.after ?? 'unknown'
32+
const commitUrl = pushPayload.head_commit?.url ?? ''
4133

4234
const bbToken = core.getInput('bb-token', { required: true })
4335
const bbUrl = core.getInput('bb-url', { required: true })
@@ -52,6 +44,7 @@ export async function run(): Promise<void> {
5244
bbProject: bbProject,
5345
bbDatabase: bbDatabase,
5446
commit: commit,
47+
commitUrl: commitUrl,
5548
c: new hc.HttpClient('bytebase-cicd-action', [], {
5649
headers: {
5750
authorization: `Bearer ${bbToken}`
@@ -167,6 +160,7 @@ export let ctx = () => {
167160
bbProject: 'db333',
168161
bbDatabase: 'instances/dbdbdb/databases/db_1',
169162
commit: '',
163+
commitUrl: '',
170164
c: new hc.HttpClient('bytebase-cicd-action', [], {
171165
headers: {
172166
authorization: `Bearer ${bbToken}`

0 commit comments

Comments
 (0)