mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-03 08:18:23 +00:00
fix(ci): align release sync with protected dev checks
This commit is contained in:
@@ -7,7 +7,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
sync-dev:
|
sync-dev:
|
||||||
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' && startsWith(github.event.release.tag_name, 'v') && !contains(github.event.release.tag_name, '-') }}
|
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' && startsWith(github.event.release.tag_name, 'v') && !contains(github.event.release.tag_name, '-') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, linux, x64]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -17,8 +17,9 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
# Always use built-in workflow token so PAT rotation never breaks sync jobs.
|
# PAT_TOKEN is required because this pushes to protected dev and must
|
||||||
token: ${{ github.token }}
|
# trigger follow-up Push CI / Dev Release workflows.
|
||||||
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
run: |
|
run: |
|
||||||
@@ -31,7 +32,7 @@ jobs:
|
|||||||
git checkout dev
|
git checkout dev
|
||||||
|
|
||||||
# Attempt merge, handle version conflicts by taking main's versions
|
# Attempt merge, handle version conflicts by taking main's versions
|
||||||
if ! git merge origin/main --no-edit -m "chore(sync): merge main into dev after release [skip ci]"; then
|
if ! git merge origin/main --no-edit -m "chore(sync): merge main into dev after release"; then
|
||||||
echo "Merge conflicts detected, resolving version files..."
|
echo "Merge conflicts detected, resolving version files..."
|
||||||
|
|
||||||
# For version files, take main's version (new stable base)
|
# For version files, take main's version (new stable base)
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { describe, expect, test } from 'bun:test';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import * as path from 'node:path';
|
||||||
|
|
||||||
|
function resolvePath(relativePath: string) {
|
||||||
|
return path.resolve(import.meta.dir, relativePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('sync dev after release workflow', () => {
|
||||||
|
test('uses protected-branch runner and token settings', () => {
|
||||||
|
const workflowPath = resolvePath('../../../../.github/workflows/sync-dev-after-release.yml');
|
||||||
|
|
||||||
|
expect(fs.existsSync(workflowPath)).toBe(true);
|
||||||
|
|
||||||
|
const workflow = fs.readFileSync(workflowPath, 'utf8');
|
||||||
|
const checkoutSection = workflow.slice(
|
||||||
|
workflow.indexOf('- name: Checkout'),
|
||||||
|
workflow.indexOf('- name: Configure Git')
|
||||||
|
);
|
||||||
|
const syncSection = workflow.slice(workflow.indexOf('- name: Sync dev with main'));
|
||||||
|
|
||||||
|
expect(workflow).toContain('name: Sync Dev After Main Release');
|
||||||
|
expect(workflow).toContain('runs-on: [self-hosted, linux, x64]');
|
||||||
|
expect(workflow).not.toContain('runs-on: ubuntu-latest');
|
||||||
|
expect(checkoutSection).toContain('token: ${{ secrets.PAT_TOKEN }}');
|
||||||
|
expect(checkoutSection).not.toContain('token: ${{ github.token }}');
|
||||||
|
expect(syncSection).toContain(
|
||||||
|
'git merge origin/main --no-edit -m "chore(sync): merge main into dev after release"'
|
||||||
|
);
|
||||||
|
expect(syncSection).not.toContain('[skip ci]');
|
||||||
|
expect(syncSection).toContain('git push origin dev');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user