Skip to content

Commit f49b6bf

Browse files
authored
Merge pull request #131 from MekDrop/fix/ci-actions-for-automerge
GitHub actions rewritten to better test code and better automerge dependency updates
2 parents d981d09 + 794c057 commit f49b6bf

File tree

7 files changed

+160
-129
lines changed

7 files changed

+160
-129
lines changed

.github/workflows/autocommit.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Autoupdate code
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: 'autobuild'
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
prepare:
17+
name: Prepare
18+
runs-on: ubuntu-latest
19+
outputs:
20+
date: ${{ steps.date.outputs.date }}
21+
steps:
22+
- name: Get current date
23+
id: date
24+
run: echo "date=$(date -u +'%Y-%m-%d %H:%M UTC')" >> $GITHUB_OUTPUT
25+
26+
update-and-commit:
27+
name: ${{ matrix.name }} and Commit
28+
needs: prepare
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
include:
33+
- operation: format
34+
name: Format code
35+
description: "Format code according to project standards"
36+
- operation: pack
37+
name: Update dist folder
38+
description: "Rebuild the distribution files"
39+
max-parallel: 1
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
with:
44+
token: ${{ secrets.IMPRESSBOT_TOKEN }}
45+
46+
- name: Set up Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '20'
50+
51+
- name: Install dependencies
52+
run: npm install
53+
54+
- name: Run ${{ matrix.operation }}
55+
run: npm run ${{ matrix.operation }}
56+
57+
- name: Commit and push if changes exist
58+
uses: stefanzweifel/git-auto-commit-action@v5
59+
with:
60+
commit_message: "${{ matrix.name }} ${{ needs.prepare.outputs.date }}"
61+
commit_user_name: ImpressBot
62+
commit_user_email: [email protected]
63+
commit_author: ImpressBot <[email protected]>

.github/workflows/autorelease.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
schedule:
66
- cron: '5 4 * */3 0'
77

8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
812
jobs:
913
auto-release:
1014
runs-on: ubuntu-latest

.github/workflows/dependabot.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Based on code from https://andre.arko.net/2022/05/15/automatic-dependabot-merges/
2+
3+
name: "Merge updates"
4+
on:
5+
workflow_run:
6+
workflows:
7+
- "Tests and Checks"
8+
types:
9+
- "completed"
10+
branches:
11+
- "dependabot/**"
12+
jobs:
13+
merge:
14+
name: "Merge"
15+
runs-on: "ubuntu-latest"
16+
if: >
17+
github.event.workflow_run.event == 'pull_request' &&
18+
github.event.workflow_run.conclusion == 'success' &&
19+
github.actor == 'dependabot[bot]'
20+
steps:
21+
- name: "Approve pull request"
22+
uses: "juliangruber/approve-pull-request-action@v2"
23+
with:
24+
github-token: "${{ secrets.IMPRESSBOT_TOKEN }}"
25+
number: "${{ github.event.workflow_run.pull_requests[0].number }}"
26+
27+
- name: "Merge pull request"
28+
uses: "actions/github-script@v7"
29+
with:
30+
github-token: "${{ secrets.GITHUB_TOKEN }}"
31+
script: |
32+
const pullRequest = context.payload.workflow_run.pull_requests[0]
33+
const repository = context.repo
34+
await github.rest.pulls.merge({
35+
merge_method: "merge",
36+
owner: repository.owner,
37+
pull_number: pullRequest.number,
38+
repo: repository.repo,
39+
})

.github/workflows/on-pull-request.yml

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

.github/workflows/test.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Tests and Checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- synchronize
10+
- reopened
11+
- ready_for_review
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
jobs:
18+
validate:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
include:
23+
- task: test
24+
name: Run tests
25+
command: test
26+
- task: format-check
27+
name: Check code formatting
28+
command: format-check
29+
- task: lint
30+
name: Lint code
31+
command: lint
32+
- task: pack
33+
name: Compile
34+
command: pack
35+
fail-fast: false
36+
name: ${{ matrix.name }}
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20.x
45+
cache: 'npm'
46+
47+
- name: Install dependencies
48+
run: npm install
49+
env:
50+
CI: true
51+
52+
- name: ${{ matrix.name }}
53+
run: npm run ${{ matrix.command }}

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "filter-php-class-list-with-glob-like-rules-action",
3-
"version": "0.0.0",
43
"description": "This action filters PHP classes list based on GLOB criteria",
54
"main": "src/index.js",
65
"type": "module",
@@ -12,7 +11,7 @@
1211
"test": "jest",
1312
"format": "prettier --write **/*.js",
1413
"format-check": "prettier --check **/*.js",
15-
"lint": "eslint src/**/*.js",
14+
"lint": "eslint --no-warn-ignored 'src/**/*.js' 'tests/**/*.js'",
1615
"pack": "ncc build --minify",
1716
"all": "npm install && npm run format && npm run lint && npm run pack",
1817
"fast-all": "npm install && npm run pack"

0 commit comments

Comments
 (0)