-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (61 loc) · 2.33 KB
/
deduplicate.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
59
60
61
62
63
64
65
66
67
68
69
70
name: Run Yarn Deduplicate on PR Command
on:
issue_comment:
types: [created]
jobs:
run-yarn-deduplicate:
if: ${{ github.event.issue.pull_request && github.event.comment.author_association == 'OWNER' && (github.event.comment.body == '/deduplicate' || github.event.comment.body == '/deduplicate fewer') }}
runs-on: ubuntu-latest
env:
STRATEGY: ${{ contains(github.event.comment.body, 'fewer') && 'fewer' || 'highest' }}
steps:
- name: Acknowlegde command and get ref
uses: actions/github-script@v7
id: github-script
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Ok, trying to deduplicate using strategy `${{ env.STRATEGY }}`'
});
var pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
return pull.data.head.ref;
- name: Check out the repository
uses: actions/checkout@v4
with:
ref: ${{ fromJson(steps.github-script.outputs.result) }}
persist-credentials: false
- name: 'Prepare workflow'
uses: ./.github/actions/prepare
- name: 'Deduplicate dependencies'
uses: ./.github/actions/deduplicate
with:
strategy: ${{ env.STRATEGY }}
- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add yarn.lock
git commit -m "chore(deps): Deduplicated dependencies using yarn-deduplicate"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: ${{ fromJson(steps.github-script.outputs.result) }}
- name: Notify of failure
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'I failed :('
})
if: failure()