mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Refactor workflows for new typescript-bot triggers (#57409)
This commit is contained in:
parent
8ada4ef44f
commit
f4eeea052e
82
.github/workflows/create-cherry-pick-pr.yml
vendored
82
.github/workflows/create-cherry-pick-pr.yml
vendored
@ -1,8 +1,6 @@
|
||||
name: Create cherry pick PR
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [create-cherry-pick-pr]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr:
|
||||
@ -13,10 +11,26 @@ on:
|
||||
description: Target branch to cherry-pick to
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Inputs provided by the bot
|
||||
distinct_id:
|
||||
description: '(bot) A distinct ID'
|
||||
required: false
|
||||
default: ''
|
||||
source_issue:
|
||||
description: '(bot) The issue that triggered this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
requesting_user:
|
||||
description: User who requested the cherry-pick
|
||||
required: true
|
||||
type: string
|
||||
description: '(bot) The user who requested this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
status_comment:
|
||||
description: '(bot) The comment to update with the status of this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@ -40,15 +54,27 @@ jobs:
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
id: open-pr
|
||||
env:
|
||||
PR: ${{ inputs.pr || github.event.client_payload.pr }}
|
||||
TARGET_BRANCH: ${{ inputs.target_branch || github.event.client_payload.target_branch }}
|
||||
REQUESTING_USER: ${{ inputs.requesting_user || github.event.client_payload.requesting_user }}
|
||||
PR: ${{ inputs.pr }}
|
||||
TARGET_BRANCH: ${{ inputs.target_branch }}
|
||||
DISTINCT_ID: ${{ inputs.distinct_id }}
|
||||
SOURCE_ISSUE: ${{ inputs.source_issue }}
|
||||
REQUESTING_USER: ${{ inputs.requesting_user }}
|
||||
STATUS_COMMENT: ${{ inputs.status_comment }}
|
||||
with:
|
||||
retries: 3
|
||||
github-token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
result-encoding: string
|
||||
script: |
|
||||
const { PR, TARGET_BRANCH, REQUESTING_USER } = process.env;
|
||||
const {
|
||||
PR,
|
||||
TARGET_BRANCH,
|
||||
DISTINCT_ID,
|
||||
SOURCE_ISSUE,
|
||||
REQUESTING_USER,
|
||||
STATUS_COMMENT,
|
||||
} = process.env;
|
||||
|
||||
const pr = await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
@ -75,6 +101,8 @@ jobs:
|
||||
head: `${context.repo.owner}:${pickBranch}`,
|
||||
});
|
||||
|
||||
let commentBody;
|
||||
|
||||
if (existingPulls.data.length === 0) {
|
||||
console.log(`No existing PRs found for ${pickBranch}`);
|
||||
|
||||
@ -91,12 +119,7 @@ jobs:
|
||||
reviewers: ["DanielRosenwasser", REQUESTING_USER],
|
||||
});
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: +PR,
|
||||
body: `Hey @${REQUESTING_USER}, I've created #${newPr.data.number} for you.`,
|
||||
});
|
||||
commentBody = `I've created #${newPr.data.number} for you.`;
|
||||
}
|
||||
else {
|
||||
const existing = existingPulls.data[0];
|
||||
@ -109,23 +132,18 @@ jobs:
|
||||
title,
|
||||
});
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: +PR,
|
||||
body: `Hey @${REQUESTING_USER}, I've updated #${existing.number} for you.`,
|
||||
});
|
||||
commentBody = `I've updated #${existing.number} for you.`;
|
||||
}
|
||||
|
||||
- run: |
|
||||
MESSAGE="Hey @$REQUESTING_USER, I was unable to cherry-pick this PR."
|
||||
MESSAGE+=$'\n\n'
|
||||
MESSAGE+="Check the logs at: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
return commentBody;
|
||||
|
||||
gh pr comment "$PR" --repo ${{ github.repository }} --body "$MESSAGE"
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
PR: ${{ inputs.pr || github.event.client_payload.pr }}
|
||||
TARGET_BRANCH: ${{ inputs.target_branch || github.event.client_payload.target_branch }}
|
||||
REQUESTING_USER: ${{ inputs.requesting_user || github.event.client_payload.requesting_user }}
|
||||
GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
|
||||
if: ${{ !cancelled() && inputs.distinct_id }}
|
||||
with:
|
||||
success_comment: ${{ steps.open-pr.outputs.result }}
|
||||
failure_comment: 'I was unable to cherry-pick this PR.'
|
||||
github_token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
distinct_id: ${{ inputs.distinct_id }}
|
||||
source_issue: ${{ inputs.source_issue }}
|
||||
requesting_user: ${{ inputs.requesting_user }}
|
||||
status_comment: ${{ inputs.status_comment }}
|
||||
|
||||
63
.github/workflows/new-release-branch.yaml
vendored
63
.github/workflows/new-release-branch.yaml
vendored
@ -1,8 +1,40 @@
|
||||
name: New Release Branch
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [new-release-branch]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch_name:
|
||||
description: Release branch name to create
|
||||
required: true
|
||||
type: number
|
||||
package_version:
|
||||
description: Release package version
|
||||
required: true
|
||||
type: string
|
||||
core_major_minor:
|
||||
description: Release core major.minor version
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Inputs provided by the bot
|
||||
distinct_id:
|
||||
description: '(bot) A distinct ID'
|
||||
required: false
|
||||
default: ''
|
||||
source_issue:
|
||||
description: '(bot) The issue that triggered this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
requesting_user:
|
||||
description: '(bot) The user who requested this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
status_comment:
|
||||
description: '(bot) The comment to update with the status of this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@ -30,12 +62,12 @@ jobs:
|
||||
npm install -g $(jq -r '.packageManager' < package.json)
|
||||
npm --version
|
||||
- run: |
|
||||
git checkout -b ${{ github.event.client_payload.branch_name }}
|
||||
sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
|
||||
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts
|
||||
git checkout -b ${{ inputs.branch_name }}
|
||||
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
|
||||
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
|
||||
npm ci
|
||||
npm install # update package-lock.json to ensure the version bump is included
|
||||
npx hereby LKG
|
||||
@ -48,5 +80,16 @@ jobs:
|
||||
git add --force ./lib
|
||||
git config user.email "typescriptbot@microsoft.com"
|
||||
git config user.name "TypeScript Bot"
|
||||
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
|
||||
git push --set-upstream origin ${{ github.event.client_payload.branch_name }}
|
||||
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
|
||||
git push --set-upstream origin ${{ inputs.branch_name }}
|
||||
|
||||
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
|
||||
if: ${{ !cancelled() && inputs.distinct_id }}
|
||||
with:
|
||||
success_comment: "I've created ${{ inputs.branch_name }} with version ${{ inputs.package_version }} for you."
|
||||
failure_comment: 'I was unable to create the new release branch.'
|
||||
github_token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
distinct_id: ${{ inputs.distinct_id }}
|
||||
source_issue: ${{ inputs.source_issue }}
|
||||
requesting_user: ${{ inputs.requesting_user }}
|
||||
status_comment: ${{ inputs.status_comment }}
|
||||
|
||||
2
.github/workflows/nightly.yaml
vendored
2
.github/workflows/nightly.yaml
vendored
@ -5,8 +5,6 @@ on:
|
||||
- cron: '0 7 * * *'
|
||||
# enable users to manually trigger with workflow_dispatch
|
||||
workflow_dispatch: {}
|
||||
repository_dispatch:
|
||||
types: [publish-nightly]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
61
.github/workflows/set-version.yaml
vendored
61
.github/workflows/set-version.yaml
vendored
@ -1,8 +1,40 @@
|
||||
name: Set branch version
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [set-version]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch_name:
|
||||
description: Release branch name to create
|
||||
required: true
|
||||
type: number
|
||||
package_version:
|
||||
description: Release package version
|
||||
required: true
|
||||
type: string
|
||||
core_major_minor:
|
||||
description: Release core major.minor version
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Inputs provided by the bot
|
||||
distinct_id:
|
||||
description: '(bot) A distinct ID'
|
||||
required: false
|
||||
default: ''
|
||||
source_issue:
|
||||
description: '(bot) The issue that triggered this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
requesting_user:
|
||||
description: '(bot) The user who requested this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
status_comment:
|
||||
description: '(bot) The comment to update with the status of this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@ -19,7 +51,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
ref: ${{ github.event.client_payload.branch_name }}
|
||||
ref: ${{ inputs.branch_name }}
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- run: |
|
||||
@ -35,11 +67,11 @@ jobs:
|
||||
# package_version - the full version string (eg, `3.9.1-rc` or `3.9.2`)
|
||||
# core_major_minor - the major.minor pair associated with the desired package_version (eg, `3.9` for `3.9.3`)
|
||||
- run: |
|
||||
sed -i -e 's/"version": ".*"/"version": "${{ github.event.client_payload.package_version }}"/g' package.json
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' src/compiler/corePublic.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
|
||||
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts
|
||||
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
|
||||
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
|
||||
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
|
||||
npm ci
|
||||
npm install # update package-lock.json to ensure the version bump is included
|
||||
npx hereby LKG
|
||||
@ -52,5 +84,16 @@ jobs:
|
||||
git add --force ./lib
|
||||
git config user.email "typescriptbot@microsoft.com"
|
||||
git config user.name "TypeScript Bot"
|
||||
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
|
||||
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
|
||||
git push
|
||||
|
||||
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
|
||||
if: ${{ !cancelled() && inputs.distinct_id }}
|
||||
with:
|
||||
success_comment: "I've set the version of ${{ inputs.branch_name }} to ${{ inputs.package_version }} for you."
|
||||
failure_comment: 'I was unable set the version.'
|
||||
github_token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
distinct_id: ${{ inputs.distinct_id }}
|
||||
source_issue: ${{ inputs.source_issue }}
|
||||
requesting_user: ${{ inputs.requesting_user }}
|
||||
status_comment: ${{ inputs.status_comment }}
|
||||
|
||||
38
.github/workflows/sync-branch.yaml
vendored
38
.github/workflows/sync-branch.yaml
vendored
@ -1,13 +1,32 @@
|
||||
name: Sync branch with master
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [sync-branch]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch_name:
|
||||
description: 'Target Branch Name'
|
||||
description: Release branch name to create
|
||||
required: true
|
||||
type: number
|
||||
|
||||
# Inputs provided by the bot
|
||||
distinct_id:
|
||||
description: '(bot) A distinct ID'
|
||||
required: false
|
||||
default: ''
|
||||
source_issue:
|
||||
description: '(bot) The issue that triggered this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
requesting_user:
|
||||
description: '(bot) The user who requested this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
status_comment:
|
||||
description: '(bot) The comment to update with the status of this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@ -26,7 +45,7 @@ jobs:
|
||||
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
with:
|
||||
ref: ${{ github.event.inputs.branch_name || github.event.client_payload.branch_name }}
|
||||
ref: ${{ inputs.branch_name }}
|
||||
filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
|
||||
fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none.
|
||||
token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
@ -42,3 +61,14 @@ jobs:
|
||||
git add --force ./lib
|
||||
git commit -m 'Update LKG'
|
||||
git push
|
||||
|
||||
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
|
||||
if: ${{ !cancelled() && inputs.distinct_id }}
|
||||
with:
|
||||
success_comment: "I've pulled main into ${{ inputs.branch_name }} for you."
|
||||
failure_comment: 'I was unable merge main into ${{ inputs.branch_name }}.'
|
||||
github_token: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
|
||||
distinct_id: ${{ inputs.distinct_id }}
|
||||
source_issue: ${{ inputs.source_issue }}
|
||||
requesting_user: ${{ inputs.requesting_user }}
|
||||
status_comment: ${{ inputs.status_comment }}
|
||||
|
||||
25
.github/workflows/twoslash-repros.yaml
vendored
25
.github/workflows/twoslash-repros.yaml
vendored
@ -1,13 +1,8 @@
|
||||
name: Twoslash Code Sample Repros
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- orta-twoslash-repros
|
||||
schedule:
|
||||
- cron: '0 8 * * *'
|
||||
repository_dispatch:
|
||||
types: [run-twoslash-repros]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
issue:
|
||||
@ -19,6 +14,26 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
# Inputs provided by the bot
|
||||
distinct_id:
|
||||
description: '(bot) A distinct ID'
|
||||
required: false
|
||||
default: ''
|
||||
source_issue:
|
||||
description: '(bot) The issue that triggered this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
requesting_user:
|
||||
description: '(bot) The user who requested this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
status_comment:
|
||||
description: '(bot) The comment to update with the status of this workflow'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
run-name: ${{ github.workflow }}${{ inputs.distinct_id && format(' (bot run {0})', inputs.distinct_id) || '' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user