-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (45 loc) · 2.36 KB
/
1_SB_issue_to_PR_synchronizer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: 1_SB_issue_to_PR_synchronizer
on:
workflow_dispatch: # Manual trigger
issues:
types: [opened, edited] # new issues will be converted to PR
pull_request_target:
# edited PRs will update the PRs commits
types: [edited]
branches:
- master
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number }}
jobs:
convert-SB-issue-to-PR-and-synchronize:
runs-on: [ubuntu-latest]
steps:
- name: Get App Token
uses: actions/create-github-app-token@v1
id: app_token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
# If this was triggered by pull_request_target it will checkout the base branch
# by default. Therefore we can trust the js code that is run below.
#
# https://github.com/actions/checkout/tree/v4/#:~:text=%23%20The%20branch%2C%20tag%20or%20SHA%20to%20checkout.%20When%20checking%20out%20the%20repository%20that%0A%20%20%20%20%23%20triggered%20a%20workflow%2C%20this%20defaults%20to%20the%20reference%20or%20SHA%20for%20that%20event.%0A%20%20%20%20%23%20Otherwise%2C%20uses%20the%20default%20branch.%0A%20%20%20%20ref%3A%20%27%27
#
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target:~:text=Last%20commit%20on%20the%20PR,PR%20base%20branch
#
# We need the js files
- name: Checkout repository
uses: actions/checkout@v4
# Use the app_token to trigger validation
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow
- name: Create a new PR from SB Issue
uses: actions/github-script@v7
with:
github-token: ${{ steps.app_token.outputs.token }}
script: |
console.log('Concurrency Group', '${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number }}');
console.log('eventType', context.eventName);
console.log('context.payload.sender', context.payload.sender)
const convertSBIssueToPRAndSynchronize = require('./.github/workflows/1_SB_issue_to_PR_synchronizer.js');
await convertSBIssueToPRAndSynchronize({ github, context });