feat: Initialize workflow
This commit is contained in:
parent
a44709eaba
commit
6bd841f773
|
@ -0,0 +1,25 @@
|
|||
name: default
|
||||
|
||||
on:
|
||||
pull_request: # To merge pull requests if not possible during the push run.
|
||||
push: # To create pull requests.
|
||||
check_run:
|
||||
types: [ completed ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
repository-projects: write
|
||||
|
||||
jobs:
|
||||
default:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: rapsealk/git-branch-strategy-action@branch-strategy-workflow
|
||||
with:
|
||||
github-token: ${{ secrets.PAT }}
|
||||
main-branch: main
|
||||
# release-branch: /^v\d+\.\d+$/ # v1.0, v1.1, ...
|
||||
# deploy-branch: cloud
|
||||
# hotfix-branch: ^hotfix/(.*)
|
||||
label: gitflow
|
46
action.yml
46
action.yml
|
@ -1,23 +1,45 @@
|
|||
name: 'The name of your action here'
|
||||
description: 'Provide a description here'
|
||||
author: 'Your name or organization here'
|
||||
name: git-branch-strategy-action
|
||||
description: Automates custom git branch strategy action.
|
||||
author: Jeongseok Kang
|
||||
|
||||
# Add your action's branding here. This will appear on the GitHub Marketplace.
|
||||
branding:
|
||||
icon: 'heart'
|
||||
color: 'red'
|
||||
icon: git-pull-request
|
||||
color: green
|
||||
|
||||
# Define your inputs here.
|
||||
inputs:
|
||||
milliseconds:
|
||||
description: 'Your input description here'
|
||||
github-token:
|
||||
description: GitHub personal access token with privilege.
|
||||
required: true
|
||||
default: '1000'
|
||||
main-branch:
|
||||
description: GitHub main branch.
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- main
|
||||
- master # legacy
|
||||
release-branch:
|
||||
description: GitHub branch to release. Allows a regex.
|
||||
default: null
|
||||
deploy-branch:
|
||||
description: Git branch to deploy service to cloud.
|
||||
default: null
|
||||
label:
|
||||
description: GitHub label for a pull request.
|
||||
default: gitflow
|
||||
# auto-merge:
|
||||
# description: Automates pull request merge.
|
||||
# type: boolean
|
||||
# default: true
|
||||
# require-merge:
|
||||
# description: Assert
|
||||
# type: boolean
|
||||
# default: false
|
||||
|
||||
# Define your outputs here.
|
||||
outputs:
|
||||
time:
|
||||
description: 'Your output description here'
|
||||
# outputs:
|
||||
# time:
|
||||
# description: 'Your output description here'
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
|
|
|
@ -66,7 +66,9 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1"
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@octokit/webhooks-types": "^7.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
|
|
36
src/main.ts
36
src/main.ts
|
@ -1,26 +1,28 @@
|
|||
import * as core from "@actions/core";
|
||||
import { wait } from "./wait";
|
||||
import * as github from "@actions/github";
|
||||
import {PullRequest, PullRequestEvent} from "@octokit/webhooks-types";
|
||||
|
||||
/**
|
||||
* The main function for the action.
|
||||
* @returns {Promise<void>} Resolves when the action is complete.
|
||||
*/
|
||||
export async function run(): Promise<void> {
|
||||
try {
|
||||
const ms: string = core.getInput("milliseconds");
|
||||
|
||||
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
||||
core.debug(`Waiting ${ms} milliseconds ...`);
|
||||
|
||||
// Log the current timestamp, wait, then log the new timestamp
|
||||
core.debug(new Date().toTimeString());
|
||||
await wait(parseInt(ms, 10));
|
||||
core.debug(new Date().toTimeString());
|
||||
|
||||
// Set outputs for other workflow steps to use
|
||||
core.setOutput("time", new Date().toTimeString());
|
||||
} catch (error) {
|
||||
// Fail the workflow run if an error occurs
|
||||
if (error instanceof Error) core.setFailed(error.message);
|
||||
switch (github.context.eventName) {
|
||||
case "pull_request": // https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
|
||||
const pullRequestEvent = github.context.payload as PullRequestEvent;
|
||||
switch (pullRequestEvent.action) {
|
||||
case "opened":
|
||||
onPullRequestOpen(pullRequestEvent.pull_request);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onPullRequestOpen(pullRequest: PullRequest) {
|
||||
core.info(`base:${pullRequest.base} head:${pullRequest.head}`);
|
||||
}
|
||||
|
|
14
src/wait.ts
14
src/wait.ts
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
* Wait for a number of milliseconds.
|
||||
* @param milliseconds The number of milliseconds to wait.
|
||||
* @returns {Promise<string>} Resolves with 'done!' after the wait is over.
|
||||
*/
|
||||
export async function wait(milliseconds: number): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
if (isNaN(milliseconds)) {
|
||||
throw new Error("milliseconds not a number");
|
||||
}
|
||||
|
||||
setTimeout(() => resolve("done!"), milliseconds);
|
||||
});
|
||||
}
|
114
yarn.lock
114
yarn.lock
|
@ -15,7 +15,17 @@
|
|||
"@actions/http-client" "^2.0.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
"@actions/http-client@^2.0.1":
|
||||
"@actions/github@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/github/-/github-6.0.0.tgz#65883433f9d81521b782a64cc1fd45eef2191ea7"
|
||||
integrity sha512-alScpSVnYmjNEXboZjarjukQEzgCRmjMv6Xj47fsdnqGS73bjJNDpiiXmp8jr0UZLdUB6d9jW63IcmddUP+l0g==
|
||||
dependencies:
|
||||
"@actions/http-client" "^2.2.0"
|
||||
"@octokit/core" "^5.0.1"
|
||||
"@octokit/plugin-paginate-rest" "^9.0.0"
|
||||
"@octokit/plugin-rest-endpoint-methods" "^10.0.0"
|
||||
|
||||
"@actions/http-client@^2.0.1", "@actions/http-client@^2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.2.0.tgz#f8239f375be6185fcd07765efdcf0031ad5df1a0"
|
||||
integrity sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==
|
||||
|
@ -647,6 +657,91 @@
|
|||
"@nodelib/fs.scandir" "2.1.5"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@octokit/auth-token@^4.0.0":
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-4.0.0.tgz#40d203ea827b9f17f42a29c6afb93b7745ef80c7"
|
||||
integrity sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==
|
||||
|
||||
"@octokit/core@^5.0.1":
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-5.1.0.tgz#81dacf0197ed7855e6413f128bd6dd9e121e7d2f"
|
||||
integrity sha512-BDa2VAMLSh3otEiaMJ/3Y36GU4qf6GI+VivQ/P41NC6GHcdxpKlqV0ikSZ5gdQsmS3ojXeRx5vasgNTinF0Q4g==
|
||||
dependencies:
|
||||
"@octokit/auth-token" "^4.0.0"
|
||||
"@octokit/graphql" "^7.0.0"
|
||||
"@octokit/request" "^8.0.2"
|
||||
"@octokit/request-error" "^5.0.0"
|
||||
"@octokit/types" "^12.0.0"
|
||||
before-after-hook "^2.2.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/endpoint@^9.0.0":
|
||||
version "9.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-9.0.4.tgz#8afda5ad1ffc3073d08f2b450964c610b821d1ea"
|
||||
integrity sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/graphql@^7.0.0":
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-7.0.2.tgz#3df14b9968192f9060d94ed9e3aa9780a76e7f99"
|
||||
integrity sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==
|
||||
dependencies:
|
||||
"@octokit/request" "^8.0.1"
|
||||
"@octokit/types" "^12.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/openapi-types@^19.1.0":
|
||||
version "19.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-19.1.0.tgz#75ec7e64743870fc73e1ab4bc6ec252ecdd624dc"
|
||||
integrity sha512-6G+ywGClliGQwRsjvqVYpklIfa7oRPA0vyhPQG/1Feh+B+wU0vGH1JiJ5T25d3g1JZYBHzR2qefLi9x8Gt+cpw==
|
||||
|
||||
"@octokit/plugin-paginate-rest@^9.0.0":
|
||||
version "9.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.5.tgz#1705bcef4dcde1f4015ee58a63dc61b68648f480"
|
||||
integrity sha512-WKTQXxK+bu49qzwv4qKbMMRXej1DU2gq017euWyKVudA6MldaSSQuxtz+vGbhxV4CjxpUxjZu6rM2wfc1FiWVg==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.4.0"
|
||||
|
||||
"@octokit/plugin-rest-endpoint-methods@^10.0.0":
|
||||
version "10.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.3.0.tgz#cba45a365ebc5dbeeca2db95466a514e69c5aa75"
|
||||
integrity sha512-c/fjpoHispRvBZuRoTVt/uALg7pXa9RQbXWJiDMk6NDkGNomuAZG7YuYYpZoxeoXv+kVRjIDTsO0e1z0pei+PQ==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.4.0"
|
||||
|
||||
"@octokit/request-error@^5.0.0":
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-5.0.1.tgz#277e3ce3b540b41525e07ba24c5ef5e868a72db9"
|
||||
integrity sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==
|
||||
dependencies:
|
||||
"@octokit/types" "^12.0.0"
|
||||
deprecation "^2.0.0"
|
||||
once "^1.4.0"
|
||||
|
||||
"@octokit/request@^8.0.1", "@octokit/request@^8.0.2":
|
||||
version "8.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-8.2.0.tgz#125c547bc3f4c0e2dfa38c6829a1cf00027fbd98"
|
||||
integrity sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==
|
||||
dependencies:
|
||||
"@octokit/endpoint" "^9.0.0"
|
||||
"@octokit/request-error" "^5.0.0"
|
||||
"@octokit/types" "^12.0.0"
|
||||
universal-user-agent "^6.0.0"
|
||||
|
||||
"@octokit/types@^12.0.0", "@octokit/types@^12.4.0":
|
||||
version "12.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-12.5.0.tgz#a60003ad6bb073e5cac936f6ecf47c834f87c058"
|
||||
integrity sha512-YJEKcb0KkJlIUNU/zjnZwHEP8AoVh/OoIcP/1IyR4UHxExz7fzpe/a8IG4wBtQi7QDEqiomVLX88S6FpxxAJtg==
|
||||
dependencies:
|
||||
"@octokit/openapi-types" "^19.1.0"
|
||||
|
||||
"@octokit/webhooks-types@^7.3.2":
|
||||
version "7.3.2"
|
||||
resolved "https://registry.yarnpkg.com/@octokit/webhooks-types/-/webhooks-types-7.3.2.tgz#c4a5049b28a6d4b0c397f4db48a9112fef579ba0"
|
||||
integrity sha512-JWOoOgtWTFnTSAamPXXyjTY5/apttvNxF+vPBnwdSu5cj5snrd7FO0fyw4+wTXy8fHduq626JjhO+TwCyyA6vA==
|
||||
|
||||
"@pkgr/core@^0.1.0":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
|
||||
|
@ -1183,6 +1278,11 @@ balanced-match@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
|
||||
before-after-hook@^2.2.0:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c"
|
||||
integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
|
@ -1440,6 +1540,11 @@ define-properties@^1.1.3, define-properties@^1.2.0, define-properties@^1.2.1:
|
|||
has-property-descriptors "^1.0.0"
|
||||
object-keys "^1.1.1"
|
||||
|
||||
deprecation@^2.0.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
|
||||
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==
|
||||
|
||||
dequal@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be"
|
||||
|
@ -3275,7 +3380,7 @@ object.values@^1.1.6, object.values@^1.1.7:
|
|||
define-properties "^1.2.0"
|
||||
es-abstract "^1.22.1"
|
||||
|
||||
once@^1.3.0:
|
||||
once@^1.3.0, once@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
|
||||
|
@ -3971,6 +4076,11 @@ undici@^5.25.4:
|
|||
dependencies:
|
||||
"@fastify/busboy" "^2.0.0"
|
||||
|
||||
universal-user-agent@^6.0.0:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.1.tgz#15f20f55da3c930c57bddbf1734c6654d5fd35aa"
|
||||
integrity sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==
|
||||
|
||||
update-browserslist-db@^1.0.13:
|
||||
version "1.0.13"
|
||||
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4"
|
||||
|
|
Loading…
Reference in New Issue