-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.77 KB
/
dependabot-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# This workflow rebuilds dist/index.js on opened pull request by Dependabot and adds it to the PR
name: dependabot-build
# Trigger workflow only on (opened or synchronised) PRs or on demand
# We trigger when the PR is synchronised so this rebuild is automatically run again when we tell
# dependabot to rebase a PR.
on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'package.json'
- 'package-lock.json'
workflow_dispatch: ~
jobs:
build:
name: Build
if: github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref || github.ref }}
token: ${{ secrets.REBUILD_PUSH_TOKEN }}
- name: Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions[bot]"
- name: Setup node
uses: actions/setup-node@v3
- name: Install dependencies
run: npm ci
- name: Build index.js
run: npm run build
- name: Check Git status
id: git_status
run: |
GIT_STATUS_OUTPUT=$(git status --porcelain)
if [[ -n "$GIT_STATUS_OUTPUT" ]]; then
echo "GIT_STATUS_MODIFIED=true" >> $GITHUB_ENV
else
echo "GIT_STATUS_MODIFIED=false" >> $GITHUB_ENV
fi
- name: Commit & push index.js
# Push only if the built index.js has changed.
if: env.GIT_STATUS_MODIFIED == 'true'
run: |
git add dist/index.js
git commit -m "Rebuild with updated deps from dependabot" -m "[dependabot skip]"
git push origin ${{ github.head_ref || github.ref }}