Skip to content

Commit

Permalink
Add GitHub's Example JS Action
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Feb 27, 2024
1 parent d139fe7 commit 4455bef
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: [push]

jobs:
hello_world_job:
runs-on: ubuntu-latest
name: A job to say hello
steps:
# To use this repository's private action,
# you must check out the repository
- name: Checkout
uses: actions/checkout@v4
- name: Hello world action step
uses: ./.github/workflows/opendds-action
id: hello
with:
who-to-greet: 'Mona the Octocat'
# Use the output from the `hello` step
- name: Get the output time
run: echo "The time was ${{ steps.hello.outputs.time }}"
1 change: 1 addition & 0 deletions .github/workflows/opendds-action/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
13 changes: 13 additions & 0 deletions .github/workflows/opendds-action/action.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions .github/workflows/opendds-action/index.js
Original file line number Diff line number Diff line change
@@ -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);
}
227 changes: 227 additions & 0 deletions .github/workflows/opendds-action/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .github/workflows/opendds-action/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "opendds-action",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0"
}
}

0 comments on commit 4455bef

Please sign in to comment.