diff --git a/.github/actions/get-node-version-from-package-lock/action.yml b/.github/actions/get-node-version-from-package-lock/action.yml new file mode 100644 index 000000000..065f4773f --- /dev/null +++ b/.github/actions/get-node-version-from-package-lock/action.yml @@ -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); \ No newline at end of file diff --git a/.github/actions/slackify-markdown/action.yml b/.github/actions/slackify-markdown/action.yml new file mode 100644 index 000000000..b5bc7cdb9 --- /dev/null +++ b/.github/actions/slackify-markdown/action.yml @@ -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 slackify-markdown@4.3.1 + - 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); + } \ No newline at end of file