Skip to content

Commit d7ec883

Browse files
committed
GitHub actions rewritten to better test code and better automerge dependency updates
1 parent 26f6692 commit d7ec883

File tree

4 files changed

+106
-55
lines changed

4 files changed

+106
-55
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: lint:fix
34+
name: Lint Fix
35+
description: "Lint Autofix"
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 & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)