feat: github aciton

This commit is contained in:
thomas
2024-04-17 18:36:43 +02:00
parent 04b1b4e565
commit 16e38ba91a
3 changed files with 3 additions and 2 deletions

13
.github/github-action/action.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node20'
main: 'index.js'

15
.github/github-action/index.js vendored Normal file
View File

@@ -0,0 +1,15 @@
const core = require('@actions/core');
const github = require('@actions/github');
try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}

View File

@@ -10,7 +10,8 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install dependencies
run: npm i @actions/core @actions/github
- name: add labels
uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains( fromJson('[ "tomalaforge", "alcaidio" , "svenson95", "jdegand", "DeveshChau", "stillst", "wandri", "webbomj", "kabrunko-dev", "Sanjar1304"]'), github.actor ) && startsWith(github.event.pull_request.title, 'Answer') }}
@@ -38,7 +39,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Hello world action step
uses: ./github-action/ # Uses an action in the root directory
uses: ./.github/github-action/ # Uses an action in the root directory
id: hello
with:
who-to-greet: 'Mona the Octocat'