Skip to content

Commit

Permalink
Add workflow to automatically build for npm changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Apr 25, 2023
1 parent eb3ba23 commit 1e36ac0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
paths-ignore:
- '**.md'
workflow_dispatch:
workflow_call:

jobs:
check-dist:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/dependabot-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run build for dependabot PRs

on:
pull_request:
types: [opened, synchronize]

permissions:
contents: write
pull-requests: read

defaults:
run:
shell: bash

jobs:
build:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
outputs:
changes_detected: ${{ steps.commit.outputs.changes_detected }}
steps:
- name: Fetch Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1

- uses: actions/checkout@v3
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.COMMIT_PAT }}

- name: Set up Node.js 16.x
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
uses:
actions/setup-node@v3
with:
node-version: 16.x

- name: Install dependencies
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
run: npm ci

- name: Run build
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
run: |
npm run build
npm run package
- name: Check if dist/ needs to be updated
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
id: commit
uses: stefanzweifel/git-auto-commit-action@v4

check-dist:
name: Call check-dist
needs: build
if: ${{ needs.build.outputs.changes_detected == 'true' }}
uses: ./.github/workflows/check-dist.yml

0 comments on commit 1e36ac0

Please sign in to comment.