chore(configure-workflow): prepare first version for testing in prod

This commit is contained in:
Eric Vantillard 2023-04-03 18:46:01 +02:00
parent b2d90ef23a
commit 6837e3de05
5 changed files with 77 additions and 39 deletions

View File

@ -54,24 +54,47 @@ function run() {
}
});
}
function hadnleEvent() {
function onPullRequestEvent(payload) {
switch (payload.action) {
case "labeled":
console.log("pull request label " + payload.label);
break;
default:
console.log("pull request action " + payload.action);
}
console.info('pull request event:', payload);
}
function onWorkflowDispatchEvent(payload) {
console.info('workflow dispatch event:', payload);
}
function onPushEvent(payload) {
console.info('push event:', payload);
}
function onReleaseEvent(payload) {
console.info('onReleaseEvent:', payload);
}
function handleEvent() {
console.info(`eventName: ${github.context.eventName}`);
switch (github.context.eventName) {
case "workflow_dispatch":
onWorkflowDispatchEvent(github.context.payload);
break;
case "push":
onPush(github.context.payload);
onPushEvent(github.context.payload);
break;
case "pull_request":
onPullRequestEvent(github.context.payload);
break;
// case "pull_request_target":
// onPullRequestEvent(github.context.payload as PullRequestEvent)
// break;
case "release":
onReleaseEvent(github.context.payload);
default:
break;
}
}
function onWorkflowDispatchEvent(payload) {
core.info(`The workflow is: ${payload.workflow}`);
}
function onPush(payload) {
core.info(`The head commit is: ${payload.head_commit}`);
}
hadnleEvent();
handleEvent();
run();

File diff suppressed because one or more lines are too long

View File

@ -1,17 +1,16 @@
{
"name": "typescript-action",
"version": "0.0.0",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "typescript-action",
"version": "0.0.0",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@octokit/webhooks-definitions": "^3.67.3"
"@actions/github": "^5.1.1"
},
"devDependencies": {
"@octokit/webhooks-types": "^6.10.0",
@ -1551,12 +1550,6 @@
"@octokit/openapi-types": "^12.11.0"
}
},
"node_modules/@octokit/webhooks-definitions": {
"version": "3.67.3",
"resolved": "https://registry.npmjs.org/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz",
"integrity": "sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA==",
"deprecated": "Use @octokit/webhooks-types, @octokit/webhooks-schemas, or @octokit/webhooks-examples instead. See https://github.com/octokit/webhooks/issues/447"
},
"node_modules/@octokit/webhooks-types": {
"version": "6.10.0",
"resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-6.10.0.tgz",
@ -9593,11 +9586,6 @@
"@octokit/openapi-types": "^12.11.0"
}
},
"@octokit/webhooks-definitions": {
"version": "3.67.3",
"resolved": "https://registry.npmjs.org/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz",
"integrity": "sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA=="
},
"@octokit/webhooks-types": {
"version": "6.10.0",
"resolved": "https://registry.npmjs.org/@octokit/webhooks-types/-/webhooks-types-6.10.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "typescript-action",
"version": "0.0.0",
"version": "0.0.1",
"private": true,
"description": "TypeScript template action",
"main": "lib/main.js",
@ -12,7 +12,8 @@
"package": "ncc build --source-map --license licenses.txt",
"test": "jest",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test",
"test-job": "npm run build && npm run package && pushd ../../../ && act --job testing-workflow-config && popd"
"test-job": "npm run build && npm run package && pushd ../../../ && act --job testing-workflow-config && popd",
"clean": "rm -rf node_modules lib .idea"
},
"repository": {
"type": "git",

View File

@ -1,6 +1,6 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import { PushEvent, WorkflowDispatchEvent } from '@octokit/webhooks-types';
import {PullRequestEvent, PushEvent, ReleaseEvent, WorkflowDispatchEvent} from '@octokit/webhooks-types';
import { wait } from "./wait";
@ -19,25 +19,51 @@ async function run(): Promise<void> {
}
}
function hadnleEvent(): void {
function onPullRequestEvent(payload: PullRequestEvent) {
switch(payload.action){
case "labeled":
console.log("pull request label "+payload.label)
break;
default:
console.log("pull request action "+payload.action)
}
console.info('pull request event:',payload)
}
function onWorkflowDispatchEvent(payload: WorkflowDispatchEvent): void {
console.info('workflow dispatch event:',payload)
}
function onPushEvent(payload: PushEvent): void {
console.info('push event:',payload)
}
function onReleaseEvent(payload: ReleaseEvent) {
console.info('onReleaseEvent:',payload)
}
function handleEvent(): void {
console.info(`eventName: ${github.context.eventName}`);
switch (github.context.eventName) {
case "workflow_dispatch":
onWorkflowDispatchEvent(github.context.payload as WorkflowDispatchEvent);
break;
case "push":
onPush(github.context.payload as PushEvent);
onPushEvent(github.context.payload as PushEvent);
break;
case "pull_request":
onPullRequestEvent(github.context.payload as PullRequestEvent)
break;
// case "pull_request_target":
// onPullRequestEvent(github.context.payload as PullRequestEvent)
// break;
case "release":
onReleaseEvent(github.context.payload as ReleaseEvent)
default:
break;
}
}
function onWorkflowDispatchEvent(payload: WorkflowDispatchEvent): void {
core.info(`The workflow is: ${payload.workflow}`);
}
function onPush(payload: PushEvent): void {
core.info(`The head commit is: ${payload.head_commit}`);
}
hadnleEvent();
handleEvent();
run();