From 71cfb26a9602e7a1d515febe9de0bcf53ee382ed Mon Sep 17 00:00:00 2001 From: Tim Warner Date: Wed, 7 Aug 2024 08:23:58 -0500 Subject: [PATCH] chore: Update GitHub Actions training link in README.md --- .github/workflows/links.yml | 13 ++++++++++--- .github/workflows/workflow.yml | 24 ++++++++++++++++++++++++ hello-world-action/README.md | 22 ++++++++++++++++++++++ hello-world-action/action.yml | 0 hello-world-action/index.js | 18 ++++++++++++++++++ 5 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/workflow.yml create mode 100644 hello-world-action/README.md create mode 100644 hello-world-action/action.yml create mode 100644 hello-world-action/index.js diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 6c87991..e968237 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -1,8 +1,15 @@ -name: Check Links +name: O'Reilly - Check Links on: workflow_dispatch: - + push: + branches: + - main + schedule: + - cron: "0 7 * * *" + pull_request: # Added pull request trigger + branches: + - main jobs: linkChecker: runs-on: ubuntu-latest @@ -12,4 +19,4 @@ jobs: - name: Check links in README.md uses: lycheeverse/lychee-action@v1.9.3 with: - args: ./README2.md + args: ./README.md diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..77bda7b --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,24 @@ +name: CI + +on: [push] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v2 + + # Run Hello World Action from the same repository + - name: Run Hello World Action + uses: ./hello-world-action # Uses an action in the hello-world-action directory + with: + name: 'Timothy' + + # Example of referencing a custom action from another repository + # - name: Run Another Custom Action + # uses: timothywarner-org/another-repo@v1 + # with: + # name: 'Example' diff --git a/hello-world-action/README.md b/hello-world-action/README.md new file mode 100644 index 0000000..4eb897f --- /dev/null +++ b/hello-world-action/README.md @@ -0,0 +1,22 @@ +# Hello World JavaScript Action + +This action prints "Hello [name]!" to the log. + +## Inputs + +### `name` + +**Required** The name to greet. Default is `"World"`. + +## Outputs + +### `time` + +The time we greeted you. + +## Example usage + +```yaml +uses: timothywarner-org/actions-cert-prep@v1 +with: + name: 'Timothy' diff --git a/hello-world-action/action.yml b/hello-world-action/action.yml new file mode 100644 index 0000000..e69de29 diff --git a/hello-world-action/index.js b/hello-world-action/index.js new file mode 100644 index 0000000..c240464 --- /dev/null +++ b/hello-world-action/index.js @@ -0,0 +1,18 @@ +const core = require('@actions/core'); +const github = require('@actions/github'); + +try { + // `name` input defined in action metadata file + const name = core.getInput('name'); + console.log(`Hello ${name}!`); + + // Get the current time + 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); +}