Skip to content

Commit

Permalink
✏️ progress: Factor out meteor-actions/setup-node.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Mar 28, 2024
1 parent 539128f commit 6873dbb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 34 deletions.
53 changes: 53 additions & 0 deletions .github/actions/meteor-setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "meteor-actions/setup-node"
description: "Set up Meteor's Node.js"
inputs:
node-version:
description: 'The Node.js version to use'
required: true
nvm-version:
description: 'The version of nvm to use in case actions/setup-node fails'
default: 'v0.39.7'
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
id: setup-node
with:
node-version: ${{ inputs.node-version }}
continue-on-error: true

- name: Install nvm
if: ${{ steps.setup-node.outcome != 'success' }}
shell: bash
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${{ inputs.nvm-version }}/install.sh | bash
export NVM_DIR="${HOME}/.nvm"
echo "NVM_DIR=${NVM_DIR}" >> "$GITHUB_ENV"
- name: Install Meteor-specific Node version via nvm
if: ${{ steps.setup-node.outcome != 'success' }}
env:
ARCH: ${{ matrix.architecture }}
NODE_VERSION: ${{ inputs.node-version }}
NVM_DIR: ${{ env.NVM_DIR }}
shell: bash
run: |
export NODE_INSTALL_PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}"
curl "https://static.meteor.com/dev-bundle-node-os/v${NODE_VERSION}/node-v${NODE_VERSION}-${ARCH}.tar.gz" | tar xzf - -C /tmp/
mkdir -p "${NODE_INSTALL_PATH}"
rm -r "${NODE_INSTALL_PATH}"
mv "/tmp/node-v${NODE_VERSION}-${ARCH}" "${NODE_INSTALL_PATH}"
- name: Use Meteor-specific Node version via nvm
if: ${{ steps.setup-node.outcome != 'success' }}
env:
NODE_VERSION: ${{ inputs.node-version }}
NVM_DIR: ${{ env.NVM_DIR }}
shell: bash
run: |
source "${NVM_DIR}/nvm.sh"
nvm use "${NODE_VERSION}"
export NODE_PATH="$(dirname $(nvm which $(node --version)))"
echo "${NODE_PATH}" >> "$GITHUB_PATH"
36 changes: 2 additions & 34 deletions .github/workflows/ci:build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,10 @@ jobs:
name: artifacts
path: artifacts

- uses: actions/setup-node@v4
id: setup-node
- name: Set up Node.js 💾
uses: meteor-actions/setup-node@v1
with:
node-version: ${{ needs.build.outputs.node-version }}
continue-on-error: true

- name: Install nvm
if: ${{ steps.setup-node.outcome != 'success' }}
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="${HOME}/.nvm"
echo "NVM_DIR=${NVM_DIR}" >> "$GITHUB_ENV"
- name: Install Meteor-specific Node version via nvm
if: ${{ steps.setup-node.outcome != 'success' }}
env:
ARCH: ${{ matrix.architecture }}
NODE_VERSION: ${{ needs.build.outputs.node-version }}
NVM_DIR: ${{ env.NVM_DIR }}
run: |
export NODE_INSTALL_PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}"
curl "https://static.meteor.com/dev-bundle-node-os/v${NODE_VERSION}/node-v${NODE_VERSION}-${ARCH}.tar.gz" | tar xzf - -C /tmp/
mkdir -p "${NODE_INSTALL_PATH}"
rm -r "${NODE_INSTALL_PATH}"
mv "/tmp/node-v${NODE_VERSION}-${ARCH}" "${NODE_INSTALL_PATH}"
- name: Use Meteor-specific Node version via nvm
if: ${{ steps.setup-node.outcome != 'success' }}
env:
NODE_VERSION: ${{ needs.build.outputs.node-version }}
NVM_DIR: ${{ env.NVM_DIR }}
run: |
source "${NVM_DIR}/nvm.sh"
nvm use "${NODE_VERSION}"
export NODE_PATH="$(dirname $(nvm which $(node --version)))"
echo "${NODE_PATH}" >> "$GITHUB_PATH"

- name: Inflate build 🧥
run: |
Expand Down

0 comments on commit 6873dbb

Please sign in to comment.