Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions GitForWindowsHelper/slash-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,88 @@ module.exports = async (context, req) => {
return `I edited the comment: ${answer.html_url}`
}

if (command === '/snapshot') {
if (owner !== activeOrg
|| repo !== 'git'
|| !req.body.issue.pull_request
) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}

await checkPermissions()
await thumbsUp()

const githubApiRequest = require('./github-api-request')
const pr = await githubApiRequest(
context,
await getToken(),
'GET',
`/repos/${owner}/${repo}/pulls/${issueNumber}`
)
const rev = pr.merge_commit_sha
if (!rev || pr.mergeable === false) {
throw new Error(`PR #${issueNumber} is not mergeable`)
}

const { queueCheckRun, updateCheckRun } = require('./check-runs')
const tagGitCheckRunTitle = `Snapshot @${rev}`
const tagGitCheckRunId = await queueCheckRun(
context,
await getToken(),
owner,
repo,
rev,
'tag-git',
tagGitCheckRunTitle,
tagGitCheckRunTitle
)

try {
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
const answer = await triggerWorkflowDispatch(
context,
await getToken(),
activeOrg,
'git-for-windows-automation',
'tag-git.yml',
'main', {
rev,
owner,
repo,
snapshot: 'true'
}
)

const { appendToIssueComment } = require('./issues')
const answer2 = await appendToIssueComment(
context,
await getToken(),
owner,
repo,
commentId,
`The \`tag-git\` workflow run [was started](${answer.html_url}) for merge commit ${rev}`
)
return `I edited the comment: ${answer2.html_url}`
} catch (e) {
await updateCheckRun(
context,
await getToken(),
owner,
repo,
tagGitCheckRunId, {
status: 'completed',
conclusion: 'failure',
output: {
title: tagGitCheckRunTitle,
summary: tagGitCheckRunTitle,
text: e.message || JSON.stringify(e, null, 2)
}
}
)
throw e
}
}

if (command === '/git-artifacts') {
if (owner !== activeOrg
|| repo !== 'git'
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ For convenience, the command can be abbreviated as `/add relnote <type> <message

**What does it do?** This triggers the `sync` GitHub workflow runs in Git for Windows' `git-sdk-*` repositories, i.e. updates them with the newest package versions as per the Pacman repositories.

### `/snapshot`

**Where can it be called?** In `git-for-windows/git`'s [Pull Requests](https://github.com/git-for-windows/git/pulls)

**What does it do?** This command builds a snapshot from the PR's temporary merge commit. It triggers [`tag-git`](https://github.com/git-for-windows/git-for-windows-automation/actions/workflows/tag-git.yml) with the merge commit SHA and `snapshot: true`. The cascading `git-artifacts` runs will build installers for all architectures, but because the merge commit is not on `main`, no snapshot will be uploaded to `git-snapshots`.

### `/git-artifacts`

**Where can it be called?** In `git-for-windows/git`'s [Pull Requests](https://github.com/git-for-windows/git/pulls)
Expand Down