Skip to content

Commit 84c2227

Browse files
authored
Merge pull request #129 from MekDrop/fix/ci-actions-for-automerge
GitHub actions rewritten to better test code and better automerge dependency updates
2 parents d9caedb + 7231e4b commit 84c2227

File tree

8 files changed

+196
-164
lines changed

8 files changed

+196
-164
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
version: 2
2-
updates:
3-
4-
- package-ecosystem: npm
5-
directory: "/"
6-
versioning-strategy: increase-if-necessary
7-
schedule:
8-
interval: monthly
9-
open-pull-requests-limit: 20
10-
labels:
11-
- dependencies
12-
13-
- package-ecosystem: "github-actions"
14-
directory: "/"
15-
schedule:
16-
interval: monthly
17-
open-pull-requests-limit: 20
18-
labels:
19-
- dependencies
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: npm
5+
directory: "/"
6+
versioning-strategy: increase-if-necessary
7+
schedule:
8+
interval: monthly
9+
open-pull-requests-limit: 20
10+
labels:
11+
- dependencies
12+
13+
- package-ecosystem: "github-actions"
14+
directory: "/"
15+
schedule:
16+
interval: monthly
17+
open-pull-requests-limit: 20
18+
labels:
19+
- dependencies

.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: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
name: Automatic releases
2-
3-
on:
4-
workflow_dispatch:
5-
schedule:
6-
- cron: '5 4 * */3 0'
7-
8-
jobs:
9-
auto-release:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Releasing if there is something new...
13-
uses: impresscms-dev/[email protected]
14-
with:
15-
release_branch: main
16-
github_token: ${{ secrets.GITHUB_TOKEN }}
17-
default_bump: patch
1+
name: Automatic releases
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 1 */6 *'
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
auto-release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Releasing if there is something new...
17+
uses: impresscms-dev/[email protected]
18+
with:
19+
release_branch: main
20+
github_token: ${{ secrets.GITHUB_TOKEN }}
21+
default_bump: patch

.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 & 125 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": "flattern-markdown-folder-structure-action",
3-
"version": "1.1.0",
43
"description": "GitHub action to flatten file structure with markdown data",
54
"main": "src/index.js",
65
"type": "module",
@@ -12,7 +11,7 @@
1211
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
1312
"format": "prettier --write **/*.js tests/**/*.js",
1413
"format-check": "prettier --check **/*.js tests/**/*.js",
15-
"lint": "eslint src/**/*.js tests/**/*.js",
14+
"lint": "eslint --no-warn-ignored 'src/**/*.js' 'tests/**/*.js'",
1615
"pack": "ncc build src/index.js --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)