mirror of
https://github.com/dependabot/fetch-metadata.git
synced 2026-03-13 18:17:13 -04:00
This is an aesthetic tweak to let the proper avatar show up: * https://github.com/orgs/community/discussions/26560 * https://github.com/actions/checkout/pull/1184
66 lines
2.4 KiB
YAML
66 lines
2.4 KiB
YAML
name: Compile dependabot updates
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
contents: write
|
|
jobs:
|
|
fetch-dependabot-metadata:
|
|
runs-on: ubuntu-latest
|
|
# We only want to check the metadata on pull_request events from Dependabot itself,
|
|
# any subsequent pushes to the PR should just skip this step so we don't go into
|
|
# a loop on commits created by the `build-dependabot-changes` job
|
|
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
# Map the step output to a job output for subsequent jobs
|
|
outputs:
|
|
dependency-type: ${{ steps.dependabot-metadata.outputs.dependency-type }}
|
|
package-ecosystem: ${{ steps.dependabot-metadata.outputs.package-ecosystem }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Fetch dependabot metadata
|
|
id: dependabot-metadata
|
|
uses: ./
|
|
with:
|
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
build-dependabot-changes:
|
|
runs-on: ubuntu-latest
|
|
needs: [fetch-dependabot-metadata]
|
|
# We only need to build the dist/ folder if the PR relates a production NPM dependency, otherwise we don't expect changes.
|
|
if: needs.fetch-dependabot-metadata.outputs.package-ecosystem == 'npm_and_yarn' && needs.fetch-dependabot-metadata.outputs.dependency-type == 'direct:production'
|
|
steps:
|
|
# Check out using a PAT so any pushed changes will trigger checkruns
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }}
|
|
|
|
- name: Read .nvmrc
|
|
id: nvm
|
|
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ steps.nvm.outputs.NVMRC }}
|
|
|
|
- name: Install NPM dependencies
|
|
run: npm ci
|
|
|
|
- name: Rebuild the dist/ directory
|
|
run: npm run build
|
|
|
|
- name: Check in any change to dist/
|
|
run: |
|
|
git add dist/
|
|
# Specifying the full email allows the avatar to show up: https://github.com/orgs/community/discussions/26560
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git commit -m "[dependabot skip] Update dist/ with build changes" || exit 0
|
|
git push
|