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 86c2586
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 32 deletions.
50 changes: 50 additions & 0 deletions .github/actions/meteor-setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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' }}
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 }}
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 }}
run: |
source "${NVM_DIR}/nvm.sh"
nvm use "${NODE_VERSION}"
export NODE_PATH="$(dirname $(nvm which $(node --version)))"
echo "${NODE_PATH}" >> "$GITHUB_PATH"
40 changes: 8 additions & 32 deletions .github/workflows/ci:build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,18 @@ jobs:
name: artifacts
path: artifacts

- uses: actions/setup-node@v4
id: setup-node
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
node-version: ${{ needs.build.outputs.node-version }}
continue-on-error: true
path: repo

- 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"
- uses: ./repo/.github/actions/meteor-setup-node
with:
node-version: ${{ needs.build.outputs.node-version }}

- 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 }}
- name: Remove checked out repo
run: |
source "${NVM_DIR}/nvm.sh"
nvm use "${NODE_VERSION}"
export NODE_PATH="$(dirname $(nvm which $(node --version)))"
echo "${NODE_PATH}" >> "$GITHUB_PATH"
rm -rf repo
- name: Inflate build 🧥
run: |
Expand Down

0 comments on commit 86c2586

Please sign in to comment.