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 24, 2023
1 parent eb3ba23 commit 2623b6c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/dependabot-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run build for dependabot PRs

on:
pull_request:
types: [opened, synchronize]

permissions:
contents: write
pull-requests: read
jobs:
build:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
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' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Node.js 16.x
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm' }}
uses:
actions/setup-node@v3
with:
node-version: 16.x
- name: Install dependencies
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm' }}
run: npm ci
- name: Run build
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm' }}
run: |
npm run build
npm run package
- name: If there are changes commit them
if: ${{ steps.dependabot-metadata.outputs.package-ecosystem == 'npm' }}
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build."
git config --global user.name "bot"
git config --global user.email "bot@example.com"
git add dist/
git commit -m "Update dist/ for dependabot"
git push
fi

0 comments on commit 2623b6c

Please sign in to comment.