Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KhudaDad414 committed Jun 4, 2024
1 parent 6adeb15 commit c066df7
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/actions/get-node-version-from-package-lock/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Specify Node version based on package-lock file version'
outputs:
version:
description: 'Node.js version number to use with actions/setup-node action'
value: ${{ steps.getnode.outputs.version }}
runs:
using: "composite"
steps:
- name: Get Node version
uses: actions/github-script@v6
id: getnode
with:
script: |
const { resolve } = require('path');
const packageLockLocation = './package-lock.json';
core.info(`Location of the packae-lock verification script is: ${ resolve(packageLockLocation) }`)
const packageLock = require(packageLockLocation);
const packageLockVersion = packageLock.lockfileVersion;
let nodeVersion;
switch (packageLockVersion) {
case 1:
nodeVersion = '14'
break;
case 2:
nodeVersion = '16'
break;
case 3:
nodeVersion = '18'
break;
default:
nodeVersion = '16'
break;
}
core.setOutput('version', nodeVersion);
42 changes: 42 additions & 0 deletions .github/actions/slackify-markdown/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Composite action that can be used in other actions or workflows.
# It does not run on its own.
# Replacement for LoveToKnow/slackify-markdown-action.

name: 'Make Markdown Pretty in Slack'
description: Action used in multiple workflows to handle convertion from markdown to slack--specific-text
inputs:
markdown:
description: Markdown content
required: true
outputs:
text:
description: Slack Markdown
value: ${{ steps.slackify.outputs.text }}
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install slackify-markdown package
shell: bash
run: npm install [email protected]
- name: Slackify
uses: actions/github-script@v6
id: slackify
env:
MARKDOWN: ${{ inputs.markdown }}
with:
script: |
const slackifyMarkdown = require('slackify-markdown');
try {
const md = process.env.MARKDOWN;
const mrkdwn = slackifyMarkdown(md);
core.setOutput('text', mrkdwn);
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit c066df7

Please sign in to comment.