Skip to content

make sure node versions match #3

make sure node versions match

make sure node versions match #3

Workflow file for this run

# Build MRjs and confirm everything passes
name: npm run
on:
workflow_dispatch:
push:
branches:
- '**' # This allows the workflow to run on all branches for the build job
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# todo - run the npm install with a dockerfile setup instead of pure
# install but not important to do right now since install isnt too long
- uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Dependencies
run: |
npm install
- name: 👷 Build
run: |
npm run build
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: ./dist
- name: Archive node_modules
run: zip -r npm-artifacts.zip ./node_modules
- name: Upload Npm Artifacts
uses: actions/upload-artifact@v3
with:
name: npm-artifacts
path: ./npm-artifacts.zip
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 21
- name: Download Npm Artifacts
uses: actions/download-artifact@v3
with:
name: npm-artifacts
- name: extract node_modules
run: unzip npm-artifacts.zip
- name: remove potentially old dist
run: |
rm -rf ./dist
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: ./dist
- name: 👷 Test
run: npm run test
check-dist:
if: github.ref == 'refs/heads/main' # This job runs only if the current branch is main
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
token: ${{ secrets.MRJS_AND_DOCS_REPO_PAT }}
- name: remove potentially old dist
run: |
rm -rf ./dist
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: ./dist
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "Changes detected. Committing and pushing."
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
commit_message=$'👷 MRjs - Auto Generated Dist 👷\n\nChanges at '"${GITHUB_SHA}"
git add .
git commit -m "$commit_message"
git -c http.extraHeader="AUTHORIZATION: basic $(echo -n x-access-token:${{ secrets.MRJS_AND_DOCS_REPO_PAT }} | base64)" push origin HEAD:main
else
echo "No changes detected. Exiting without committing."
fi