Skip to content

Commit 55660a8

Browse files
author
keindev
committed
workflow: rebuild configs
1 parent 8087bb4 commit 55660a8

File tree

7 files changed

+56
-270
lines changed

7 files changed

+56
-270
lines changed
File renamed without changes.

.github/scripts/config.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/auto-merge.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
name: Auto merge
2-
3-
on:
4-
pull_request:
5-
branches:
6-
- 'dev'
1+
name: Dependabot auto-merge
2+
on: pull_request
73

84
permissions:
9-
pull-requests: write
105
contents: write
6+
pull-requests: write
117

128
jobs:
13-
auto-merge:
9+
dependabot:
1410
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
1512
steps:
16-
- uses: actions/checkout@v2
17-
- uses: ahmadnassri/action-dependabot-auto-merge@v2
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@v1.1.1
1816
with:
19-
target: minor
20-
github-token: ${{ secrets.AUTO_MERGE_TOKEN }}
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
- name: Enable auto-merge for Dependabot PRs
19+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
20+
run: gh pr merge --auto --merge "$PR_URL"
21+
env:
22+
PR_URL: ${{github.event.pull_request.html_url}}
23+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
24+

.github/workflows/build.yml

Lines changed: 25 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,19 @@ on:
1010
- '*'
1111

1212
jobs:
13-
config:
14-
name: Configure
15-
runs-on: ubuntu-latest
16-
outputs:
17-
config: ${{ steps.set-config.outputs.config }}
18-
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@v2
21-
22-
- name: Setup Node.js
23-
uses: actions/setup-node@v2
24-
25-
- name: Create config
26-
id: set-config
27-
run: |
28-
echo Node: $(node -v)
29-
echo NPM: $(npm -v)
30-
npm i semver
31-
CONFIG=$(node ./.github/scripts/config.js | sed 's/ //g')
32-
echo "::set-output name=config::$CONFIG"
33-
echo $CONFIG
34-
3513
test:
3614
name: Test
37-
needs: [ config ]
38-
strategy:
39-
matrix: ${{ fromJson(needs.config.outputs.config).node.matrix }}
40-
runs-on: ${{ matrix.os }}
15+
runs-on: ubuntu-latest
16+
env:
17+
NODE_VERSION: 16
4118
steps:
4219
- name: Checkout repository
43-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
4421

45-
- name: Setup Node.js v${{ matrix.node }}
46-
uses: actions/setup-node@v2
47-
with:
48-
node-version: ${{ matrix.node }}
49-
50-
- name: Cache node modules
51-
id: cache-npm
52-
uses: actions/cache@v2
22+
- name: Setup Node.js v${{ env.NODE_VERSION }}
23+
uses: actions/setup-node@v3
5324
with:
54-
path: ~/.npm
55-
key: npm-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
25+
node-version: ${{ env.NODE_VERSION }}
5626

5727
- name: Install Dependencies
5828
run: npm ci
@@ -65,34 +35,26 @@ jobs:
6535
npm run test
6636
6737
- name: Cache coverage
68-
if: ${{ success() && matrix.node == '16.x' }}
69-
uses: actions/cache@v2
38+
uses: actions/cache@v3
7039
with:
7140
path: coverage
72-
key: coverage-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
41+
key: coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
7342

7443
build:
7544
name: Build
76-
needs: [ test, config ]
45+
needs: [ test ]
46+
runs-on: ubuntu-latest
7747
env:
78-
NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }}
79-
runs-on: ${{ fromJson(needs.config.outputs.config).node.main.os }}
48+
NODE_VERSION: 16
8049
steps:
8150
- name: Checkout repository
82-
uses: actions/checkout@v2
51+
uses: actions/checkout@v3
8352

8453
- name: Use Node.js ${{ env.NODE_VERSION }}
85-
uses: actions/setup-node@v2
54+
uses: actions/setup-node@v3
8655
with:
8756
node-version: ${{ env.NODE_VERSION }}
8857

89-
- name: Cache node modules
90-
id: cache-npm
91-
uses: actions/cache@v2
92-
with:
93-
path: ~/.npm
94-
key: npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
95-
9658
- name: Install Dependencies
9759
run: npm ci
9860
env:
@@ -104,35 +66,27 @@ jobs:
10466
coverage:
10567
name: Coverage
10668
if: ${{ github.event_name == 'push' }}
107-
needs: [ build, config ]
69+
needs: [ build ]
70+
runs-on: ubuntu-latest
10871
env:
109-
NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }}
110-
runs-on: ${{ fromJson(needs.config.outputs.config).node.main.os }}
72+
NODE_VERSION: 16
11173
steps:
11274
- name: Checkout repository
113-
uses: actions/checkout@v2
75+
uses: actions/checkout@v3
11476

11577
- name: Cache coverage
11678
id: cache-coverage
117-
uses: actions/cache@v2
79+
uses: actions/cache@v3
11880
with:
11981
path: coverage
12082
key: coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }}
12183

12284
- name: Setup Node.js v${{ env.NODE_VERSION }}
12385
if: steps.cache-coverage.outputs.cache-hit != 'true'
124-
uses: actions/setup-node@v2
86+
uses: actions/setup-node@v3
12587
with:
12688
node-version: ${{ env.NODE_VERSION }}
12789

128-
- name: Cache node modules
129-
if: steps.cache-coverage.outputs.cache-hit != 'true'
130-
id: cache-npm
131-
uses: actions/cache@v2
132-
with:
133-
path: ~/.npm
134-
key: npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
135-
13690
- name: Test
13791
if: steps.cache-coverage.outputs.cache-hit != 'true'
13892
run: |
@@ -142,7 +96,7 @@ jobs:
14296
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14397

14498
- name: Send coverage report
145-
uses: codecov/codecov-action@v1
99+
uses: codecov/codecov-action@v3
146100
with:
147101
file: ./coverage/lcov.info
148102

@@ -159,77 +113,10 @@ jobs:
159113
USER: admin:${{ secrets.GITHUB_TOKEN }}
160114
FILTER: "[.jobs[] | select(.status==\"completed\" and .conclusion==\"failure\") | { status: .conclusion, matrix: .name}] | length"
161115
run: |
162-
failure_count=$(curl -X GET -s -u $USER $URL | jq "$FILTER")
163-
echo "::set-output name=failure_count::$failure_count"
164-
echo Failure jobs count: $failure_count
116+
FAILURE_COUNT=$(curl -X GET -s -u $USER $URL | jq "$FILTER")
117+
echo "fails=$FAILURE_COUNT" >> $GITHUB_OUTPUT
118+
echo Failure jobs count: $FAILURE_COUNT
165119
166-
- if: ${{ steps.status.outputs.failure_count > 0 }}
120+
- if: ${{ steps.status.outputs.fails > 0 }}
167121
name: Fail
168122
run: exit 1
169-
170-
discord:
171-
name: Discord notification
172-
needs: [ status ]
173-
if: ${{ always() }}
174-
runs-on: ubuntu-latest
175-
env:
176-
DISCORD_USERNAME: github
177-
DISCORD_ERROR_COLOR: 16726645
178-
DISCORD_ERROR_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-error.png
179-
DISCORD_EVENT_COLOR: 53759
180-
DISCORD_EVENT_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-event.png
181-
steps:
182-
- name: Send error notification after push commit
183-
if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'push' }}
184-
uses: sarisia/actions-status-discord@v1
185-
with:
186-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
187-
nodetail: true
188-
username: ${{ env.DISCORD_USERNAME }}
189-
avatar_url: ${{ env.DISCORD_ERROR_AVATAR }}
190-
title: 'Build failed :confused:'
191-
color: ${{ env.DISCORD_ERROR_COLOR }}
192-
description: |
193-
**Repository:** `${{ github.repository }}`
194-
**Branch:** `${{ github.event.ref }}`
195-
**Author:** [${{ github.event.head_commit.author.username }}](https://github.com/${{ github.event.head_commit.author.username }})
196-
**Commit:** [${{ github.event.head_commit.id }}](${{ github.event.head_commit.url }})
197-
**Message:**
198-
`${{ github.event.head_commit.message }}`
199-
200-
- name: Send error notification for pull_request
201-
if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }}
202-
uses: sarisia/actions-status-discord@v1
203-
with:
204-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
205-
nodetail: true
206-
username: ${{ env.DISCORD_USERNAME }}
207-
avatar_url: ${{ env.DISCORD_ERROR_AVATAR }}
208-
title: 'Pull request build failed :confused:'
209-
color: ${{ env.DISCORD_ERROR_COLOR }}
210-
description: |
211-
**Repository:** `${{ github.repository }}`
212-
**Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}`
213-
**Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}})
214-
**Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}`
215-
**Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}`
216-
217-
- name: Send success notification for pull_request
218-
if: ${{ !contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }}
219-
uses: sarisia/actions-status-discord@v1
220-
with:
221-
webhook: ${{ secrets.DISCORD_WEBHOOK }}
222-
nodetail: true
223-
username: ${{ env.DISCORD_USERNAME }}
224-
avatar_url: ${{ env.DISCORD_EVENT_AVATAR }}
225-
title: 'Pull request successfully build :face_with_monocle:'
226-
color: ${{ env.DISCORD_EVENT_COLOR }}
227-
description: |
228-
**Repository:** `${{ github.repository }}`
229-
**Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}`
230-
**Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}})
231-
**Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}`
232-
**Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}`
233-
234-
235-

0 commit comments

Comments
 (0)