Skip to content

Add cmd + option + arrow keys to navigate between tabs #44

Add cmd + option + arrow keys to navigate between tabs

Add cmd + option + arrow keys to navigate between tabs #44

name: Mirror New Issues
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
issue_number:
description: "Issue number to mirror"
required: true
type: number
jobs:
mirror-issue:
name: Mirror Issue
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
env:
TARGET_REPO_ORG: ${{ secrets.WARP_ISSUES_REPO_ORG }}
TARGET_REPO_NAME: ${{ secrets.WARP_ISSUES_REPO_NAME }}
TARGET_APP_ID: ${{ secrets.WARP_ISSUES_APP_ID }}
TARGET_APP_PRIVATE_KEY: ${{ secrets.WARP_ISSUES_APP_PRIVATE_KEY }}
steps:
- name: Validate configuration
run: |
if [ -z "${TARGET_REPO_ORG}" ]; then
echo "secrets.WARP_ISSUES_REPO_ORG must be set to the destination owner."
exit 1
fi
if [ -z "${TARGET_REPO_NAME}" ]; then
echo "secrets.WARP_ISSUES_REPO_NAME must be set to the destination repository name."
exit 1
fi
if [ "${TARGET_REPO_ORG}/${TARGET_REPO_NAME}" = "${{ github.repository }}" ]; then
echo "The destination repository must be different from ${{ github.repository }}."
exit 1
fi
if [ -z "${TARGET_APP_ID}" ]; then
echo "secrets.WARP_ISSUES_APP_ID must be set to the GitHub App ID."
exit 1
fi
if [ -z "${TARGET_APP_PRIVATE_KEY}" ]; then
echo "secrets.WARP_ISSUES_APP_PRIVATE_KEY must be set to the GitHub App private key."
exit 1
fi
- name: Mint GitHub App installation token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.WARP_ISSUES_APP_ID }}
private-key: ${{ secrets.WARP_ISSUES_APP_PRIVATE_KEY }}
owner: ${{ secrets.WARP_ISSUES_REPO_ORG }}
repositories: ${{ secrets.WARP_ISSUES_REPO_NAME }}
- name: Load source issue
if: ${{ github.event_name == 'workflow_dispatch' }}
id: source-issue
uses: actions/github-script@v7
with:
script: |
const issueNumberInput = context.payload.inputs?.issue_number;
const issueNumber = Number(issueNumberInput);
if (!Number.isInteger(issueNumber) || issueNumber <= 0) {
core.setFailed(`Invalid issue_number input: "${issueNumberInput}".`);
return;
}
const response = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
});
core.setOutput("title", response.data.title);
core.setOutput("body", response.data.body ?? "");
core.setOutput("html_url", response.data.html_url);
- name: Mirror issue
uses: actions/github-script@v7
env:
SOURCE_ISSUE_TITLE: ${{ steps.source-issue.outputs.title }}
SOURCE_ISSUE_BODY: ${{ steps.source-issue.outputs.body }}
SOURCE_ISSUE_HTML_URL: ${{ steps.source-issue.outputs.html_url }}
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const targetOwner = process.env.TARGET_REPO_ORG;
const targetName = process.env.TARGET_REPO_NAME;
if (!targetOwner || !targetName) {
core.setFailed(
"secrets.WARP_ISSUES_REPO_ORG and secrets.WARP_ISSUES_REPO_NAME must both be set.",
);
return;
}
let issue;
if (context.eventName === "workflow_dispatch") {
if (!process.env.SOURCE_ISSUE_TITLE || !process.env.SOURCE_ISSUE_HTML_URL) {
core.setFailed("Failed to load the source issue.");
return;
}
issue = {
title: process.env.SOURCE_ISSUE_TITLE,
body: process.env.SOURCE_ISSUE_BODY,
html_url: process.env.SOURCE_ISSUE_HTML_URL,
};
} else {
issue = context.payload.issue;
}
const mirroredBody = issue.body?.trim()
? `[Original issue](${issue.html_url})\n\n${issue.body}`
: `[Original issue](${issue.html_url})`;
await github.rest.issues.create({
owner: targetOwner,
repo: targetName,
title: issue.title,
body: mirroredBody,
});