Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/actions-dist-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: "Actions Dist - Node"

on:
workflow_call:
inputs:
node-version:
description: "Node.js version"
required: true
type: string
default: "20.x"
dependabot-autodist:
description: "Whether to update the dist folder for dependabot commits"
type: string
default: "false"
dependabot-branch:
description: "The branch to push the dist folder to"
type: string
default: "main"

jobs:
dist-check:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This job does not depend on the other, is that intentional? If so it is kind of doing what the other one is with a little more, so why the two?

# Checks the dist folder for uncommitted changes in Pull Requests
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.event_name == 'pull_request'

permissions:
contents: read
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: ${{ github.event.inputs.node-version }}

- name: "Install and Build"
run: |
npm install

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm ci is probably the one you want here unless you want to update packages, ci will strictly follow the lock file and fail if there is a dependency not in it that would be installed

npm run bundle --if-present

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe introduce the script names of bundle and bundle-exe as inputs that are defaulted, this is not a standard naming convention

npm run bundle-exe --if-present

- name: "Check for uncommitted changes"
id: diff

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have an id, it is not being referenced anywhere

run: |
git diff --exit-code

dist-dependabot:
# Update the dist folder for dependabot commits in the specified branch
runs-on: ubuntu-latest
if: inputs.dependabot-autodist == 'true' && github.actor == 'dependabot[bot]' && github.event_name == 'push' && github.ref == 'refs/heads/${{ inputs.dependabot-branch }}'

permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version: ${{ github.event.inputs.node-version }}

- name: "Install and Build"
run: |
npm install
npm run bundle --if-present
npm run bundle-exe --if-present

- name: Check that build is clean
id: clean_build
continue-on-error: true
run: |
git diff --exit-code

- name: Update release
if: steps.clean_build.outcome == 'failure'
run: |
git config user.name github-actions
git config user.email [email protected]

git add .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know this to be the dist directory or something the user can specify, maybe lock it to that and then ensure that there are no extra changes outside of that, as that is sign something "additional" happened that was not expected?

git commit -m "chore: Updating release files"
git push origin ${{ github.head_ref }}