Split workflow processes. (#588)

* Split workflow processes.

* fix
This commit is contained in:
Nerivec
2024-11-01 02:04:23 +01:00
committed by GitHub
parent 0f1b5bd4e2
commit 2da322c5b0
24 changed files with 698 additions and 404 deletions

45
.github/workflows/check_ota_pr.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Check OTA PR
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [master]
paths: ['images/**']
jobs:
check-ota-pr:
runs-on: ubuntu-latest
# don't run if PR was closed without merge, or explicitly disabled
if: |
!contains(github.event.pull_request.labels.*.name, 'ignore-ota-workflow')
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Check OTA PR
uses: actions/github-script@v7
with:
script: |
const {checkOtaPR} = await import("${{ github.workspace }}/dist/ghw_check_ota_pr.js")
await checkOtaPR(github, core, context)
- uses: actions/upload-artifact@v4
if: always()
with:
name: pr
path: pr/

View File

@@ -11,22 +11,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Lint
run: |
pnpm run format:check
pnpm run eslint
- name: Test
# NOTE: see jest.config.ts `collectCoverageFrom`
run: pnpm run coverage

View File

@@ -13,18 +13,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Concat CACerts
uses: actions/github-script@v7
with:
@@ -32,6 +37,7 @@ jobs:
const {concatCaCerts} = await import("${{ github.workspace }}/dist/ghw_concat_cacerts.js")
await concatCaCerts(github, core, context)
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'

View File

@@ -16,18 +16,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Overwrite cache
uses: actions/github-script@v7
with:
@@ -35,6 +40,7 @@ jobs:
const {overwriteCache} = await import("${{ github.workspace }}/dist/gwh_overwrite_cache.js")
await overwriteCache(github, core, context, "${{ inputs.manufacturers || '' }}")
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'

44
.github/workflows/report_ota_pr.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Report OTA PR
on:
workflow_run:
workflows: ['Check OTA PR']
types:
- completed
permissions:
contents: read
pull-requests: write
actions: read
jobs:
report-ota-pr:
runs-on: ubuntu-latest
# should never be anything else...
if: |
github.event.workflow_run.event == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Check OTA PR
uses: actions/github-script@v7
with:
script: |
const {reportOtaPR} = await import("${{ github.workspace }}/dist/ghw_report_ota_pr.js")
await reportOtaPR(github, core, context)

View File

@@ -22,18 +22,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Create and checkout new branch
id: create_branch
run: |
@@ -42,6 +47,7 @@ jobs:
branch_name="reprocess-$(date +'%Y-%m-%d-%H-%M-%S')"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
git checkout -b $branch_name
- name: Reprocess
uses: actions/github-script@v7
env:
@@ -51,11 +57,13 @@ jobs:
const {reProcessAllImages} = await import("${{ github.workspace }}/dist/ghw_reprocess_all_images.js")
await reProcessAllImages(github, core, context, ${{ fromJSON(inputs.remove_not_in_manifest) }}, true)
- name: Commit changes in new branch
run: |
git add .
git commit -m "Re-Processed all images" || echo 'Nothing to commit'
git push -u origin HEAD
- name: Create pull request
uses: actions/github-script@v7
with:

View File

@@ -28,18 +28,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Run Autodl
uses: actions/github-script@v7
env:
@@ -51,6 +56,7 @@ jobs:
const {runAutodl} = await import("${{ github.workspace }}/dist/ghw_run_autodl.js")
await runAutodl(github, core, context, "${{ inputs.manufacturers || '' }}")
- name: Create Autodl release
uses: actions/github-script@v7
with:
@@ -58,6 +64,7 @@ jobs:
const {createAutodlRelease} = await import("${{ github.workspace }}/dist/ghw_create_autodl_release.js")
await createAutodlRelease(github, core, context)
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'

View File

@@ -1,50 +1,43 @@
name: Update OTA PR
name: Update manifests
on:
pull_request:
types: [opened, synchronize, reopened, edited, closed]
push:
branches: [master]
paths: ['images/**']
permissions:
contents: write
pull-requests: write
jobs:
update-pr:
update-manifests:
runs-on: ubuntu-latest
# don't run if PR was closed without merge, or explicitly disabled
if: |
!contains(github.event.pull_request.labels.*.name, 'ignore-ota-workflow') && (github.event.action != 'closed' || github.event.pull_request.merged == true)
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Build
run: pnpm run build
- name: Get changed files
run: |
files=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path' | tr '\n' ',')
echo "files=$files" >> $GITHUB_OUTPUT
id: changed_files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update PR
- name: Update manifests
uses: actions/github-script@v7
with:
script: |
const {updateOtaPR} = await import("${{ github.workspace }}/dist/ghw_update_ota_pr.js")
const {updateManifests} = await import("${{ github.workspace }}/dist/ghw_update_manifests.js")
await updateManifests(github, core, context)
await updateOtaPR(github, core, context, "${{steps.changed_files.outputs.files}}")
- name: Commit changes on push
if: github.event.pull_request.merged == true
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'