feat: automate dist recompilation on Renovate PRs and configure concurrency limit #120
@@ -0,0 +1,53 @@
|
||||
name: Recompile dist/ on Renovate PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
paths:
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
- index.js
|
||||
- monitor.js
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
recompile:
|
||||
runs-on: pi
|
||||
if: |
|
||||
(github.actor == 'renovate[bot]' || contains(github.head_ref, 'renovate/')) &&
|
||||
!contains(github.event.head_commit.message, '[skip compile]')
|
||||
steps:
|
||||
- name: Checkout PR Branch
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
|
||||
- name: Clean Install
|
||||
run: pnpm install --frozen-lockfile --ignore-scripts
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
shell: bash
|
||||
|
||||
- name: Commit dist/
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add dist/
|
||||
if git diff --staged --quiet; then
|
||||
echo "No changes to dist/"
|
||||
|
Philipp marked this conversation as resolved
|
||||
else
|
||||
git commit -m "chore: compile action bundle [skip compile]"
|
||||
git push origin HEAD:${{ github.head_ref }}
|
||||
fi
|
||||
shell: bash
|
||||
@@ -2,6 +2,7 @@ name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
name: Recompile dist/ on Renovate PR
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
paths:
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
- index.js
|
||||
- monitor.js
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
recompile:
|
||||
# 1. Only run for Renovate branches
|
||||
# 2. Never run if the last commit was already our automated build commit
|
||||
if: |
|
||||
(github.actor == 'renovate[bot]' || contains(github.head_ref, 'renovate/')) &&
|
||||
!startsWith(github.event.pull_request.head.label, 'recompile-dist') &&
|
||||
!contains(github.event.head_commit.message, '[skip compile]')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate App Token
|
||||
id: app-token
|
||||
if: ${{ env.RECOMPILE_APP_ID != '' }}
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.RECOMPILE_APP_ID }}
|
||||
private-key: ${{ secrets.RECOMPILE_APP_PRIVATE_KEY }}
|
||||
env:
|
||||
RECOMPILE_APP_ID: ${{ secrets.RECOMPILE_APP_ID }}
|
||||
|
||||
- name: Checkout PR Branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token || github.token }}
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: pnpm
|
||||
|
||||
- name: Clean Install (No Lifecycle Scripts)
|
||||
run: pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Commit dist/
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_user_name: github-actions[bot]
|
||||
commit_user_email: github-actions[bot]@users.noreply.github.com
|
||||
commit_message: 'chore: compile action bundle [skip compile]'
|
||||
file_pattern: dist/*
|
||||
@@ -7,6 +7,7 @@ This repository is maintained by Gemini.
|
||||
* **Test-Driven Development (TDD):** Wherever possible, Test-Driven Development principles should be followed. Write tests before writing the code they are intended to validate.
|
||||
* **Pre-commit Hooks:** Ensure that `pre-commit` hooks are installed and active before making any commits. This can be done by running `pre-commit install` in your local repository.
|
||||
* **Note for Gemini:** Git commits trigger pre-commit hooks, which can take several seconds (or minutes) to complete. Checking the command status for git commit is only appropriate every 120s.
|
||||
* **Package Manager Preferences:** Always use `pnpm` and `pnpx`. Never use `npm` or `npx` under any circumstances. All package management operations, script runs, and tool invocations must use `pnpm` / `pnpx`.
|
||||
|
||||
## Repository Comparison
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { vi, describe, it, expect, beforeEach } from "vitest";
|
||||
import { vi, describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
|
||||
// Mock @actions/core for all tests in this file
|
||||
vi.mock("@actions/core", () => ({
|
||||
|
||||
+6
-15
@@ -5,20 +5,11 @@
|
||||
"config:recommended",
|
||||
":automergeLinters"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchManagers": [
|
||||
"pnpm"
|
||||
],
|
||||
"postUpgradeTasks": {
|
||||
"commands": [
|
||||
"pnpm install --frozen-lockfile",
|
||||
"pnpm run build"
|
||||
],
|
||||
"fileFilters": [
|
||||
"dist/index.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
"rebaseWhen": "behind-base-branch",
|
||||
"branchConcurrentLimit": 2,
|
||||
"prConcurrentLimit": 2,
|
||||
"gitIgnoredAuthors": [
|
||||
"github-actions[bot]@users.noreply.github.com",
|
||||
"bot@horstenkamp.eu"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user
The use of
[skip compile]in the commit message is a good way to prevent circular workflow triggers. Ensure this is consistent if you add other workflows that commit back to the repo.