Skip to content

Commit fb0cd5b

Browse files
author
Julian Alejandro Albarellos
authored
feat: add public mirror intake workflow (#979)
1 parent d3711ff commit fb0cd5b

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ------------------------------------------------------------------------------
2+
# DO NOT MODIFY — This workflow is part of the public mirror infrastructure
3+
# and is managed by the repository maintainers. Pull requests that modify
4+
# this file will not be accepted.
5+
# ------------------------------------------------------------------------------
6+
name: Public mirror — intake
7+
8+
on:
9+
pull_request_target:
10+
types: [opened, synchronize, reopened]
11+
12+
permissions: {}
13+
14+
jobs:
15+
notify-private:
16+
if: ${{ vars.PUB_SYNC_PRIVATE_ORG != '' &&
17+
github.repository_owner != vars.PUB_SYNC_PRIVATE_ORG }}
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Generate token for private org
21+
id: app-token
22+
uses: actions/create-github-app-token@v3
23+
with:
24+
client-id: ${{ vars.PUB_SYNC_INTAKE_APP_ID }}
25+
private-key: ${{ secrets.PUB_SYNC_INTAKE_APP_KEY }}
26+
owner: ${{ vars.PUB_SYNC_PRIVATE_ORG }}
27+
repositories: ${{ github.event.repository.name }}
28+
- name: Dispatch intake event to private repo
29+
env:
30+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
31+
PRIVATE_ORG: ${{ vars.PUB_SYNC_PRIVATE_ORG }}
32+
REPO_NAME: ${{ github.event.repository.name }}
33+
PR_NUMBER: ${{ github.event.pull_request.number }}
34+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
35+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
36+
BASE_REF: ${{ github.event.pull_request.base.ref }}
37+
PR_TITLE: ${{ github.event.pull_request.title }}
38+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
39+
PR_URL: ${{ github.event.pull_request.html_url }}
40+
run: |
41+
jq -n \
42+
--arg num "$PR_NUMBER" \
43+
--arg sha "$HEAD_SHA" \
44+
--arg headrepo "$HEAD_REPO" \
45+
--arg base "$BASE_REF" \
46+
--arg title "$PR_TITLE" \
47+
--arg author "$PR_AUTHOR" \
48+
--arg url "$PR_URL" \
49+
--arg action "${{ github.event.action }}" \
50+
'{event_type: "public-pr-intake", client_payload: {
51+
public_pr_number: $num, head_sha: $sha, head_repo: $headrepo,
52+
base_ref: $base, title: $title, author: $author,
53+
url: $url, action: $action }}' \
54+
| gh api "repos/${PRIVATE_ORG}/${REPO_NAME}/dispatches" --input -

0 commit comments

Comments
 (0)