Skip to content

Commit

Permalink
Mirror design reviews to a private discussion repository (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyasskin authored Sep 5, 2024
1 parent 14773b3 commit acc6378
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/mirror-issues-for-discussion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Mirror issues for brainstorming

on:
issues:
types:
- reopened
- opened
- closed

env:
ORG: w3ctag
SOURCE_REPO: design-reviews
MIRROR_REPO: design-reviews-private-brainstorming
# Requires Contents: read and Issues: read/write permissions on the MIRROR_REPO.
GH_TOKEN: ${{ secrets.PRIVATE_BRAINSTORMING_GITHUB_TOKEN }}

jobs:
open:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' }}
steps:
- name: "Copy issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
run: |
gh issue create --title "$TITLE" --body "Mirrored from: $ORG/$SOURCE_REPO#$ISSUE_ID
$ISSUE_BODY" --repo "$ORG/$MIRROR_REPO"
env:
TITLE: ${{ github.event.issue.title }}
ISSUE_ID: ${{ github.event.issue.number }}
ISSUE_BODY: ${{ github.event.issue.body }}

update-state:
runs-on: ubuntu-latest
if: ${{ github.event.action != 'opened' }}
steps:
- name: Find mirrored issue number
run: |
mirroredIssue=$(gh api graphql -F q="\"Mirrored from: $ORG/$SOURCE_REPO#$ISSUE_ID\" in:body is:issue repo:$ORG/$MIRROR_REPO" -f query='
query($q: String!) {
search(type: ISSUE, query: $q, first: 1) {
nodes {
... on Issue {
number
}
}
}
}
' --jq=.data.search.nodes[].number)
if [ -z "$mirroredIssue" ]; then
echo "::error ::Can't find a mirror of $ORG/$SOURCE_REPO#$ISSUE_ID."
exit 1
fi
echo 'MIRRORED_ISSUE='$mirroredIssue >> $GITHUB_ENV
echo "::debug::Found issue #$mirroredIssue."
env:
ISSUE_ID: ${{ github.event.issue.number }}
- if: ${{ github.event.action == 'closed' }}
name: Close mirrored issue
run: |
gh issue close $MIRRORED_ISSUE --repo "$ORG/$MIRROR_REPO"
echo "Closed issue $ORG/$MIRROR_REPO#$MIRRORED_ISSUE" >> $GITHUB_STEP_SUMMARY
- if: ${{ github.event.action == 'reopened' }}
name: Reopen mirrored issue
run: |
gh issue reopen $MIRRORED_ISSUE --repo "$ORG/$MIRROR_REPO"
echo "Reopened issue $ORG/$MIRROR_REPO#$MIRRORED_ISSUE" >> $GITHUB_STEP_SUMMARY

0 comments on commit acc6378

Please sign in to comment.