-
Notifications
You must be signed in to change notification settings - Fork 277
67 lines (62 loc) · 2.66 KB
/
create-oss-pr-snapshot-in-cloud.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Create Pull Request Snapshot in Cloud
on:
issue_comment:
types: [created]
jobs:
check:
if: startsWith(github.head_ref, 'main') != true
runs-on: ubuntu-latest
outputs:
pull_request_branch: ${{ steps.comment-branch.outputs.head_ref }}
branch_up_to_date: ${{ steps.branch-up-to-date.outputs.up_to_date }}
repo_full_name: ${{ steps.get-branch-and-repo.outputs.repo_full_name }}
steps:
- id: get-branch-and-repo
run: |
echo "repo_full_name=$(curl ${{ github.event.issue.pull_request.url }} | jq --raw-output .head.repo.full_name)" >> $GITHUB_OUTPUT
- uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- uses: actions/checkout@v3
with:
repository: ${{ steps.get-branch-and-repo.outputs.repo_full_name }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
fetch-depth: 0 # needed to have the base branch available for the action below
- uses: stefanluptak/check-branch-up-to-date@v1
id: branch-up-to-date
with:
base_branch: 'main'
head_branch: ${{ steps.comment-branch.outputs.head_ref }}
dispatch_command_to_cloud:
needs: check
runs-on: ubuntu-latest
steps:
- name: Create a snapshot of an OSS PR to Cloud
if: needs.check.outputs.branch_up_to_date == 'true'
uses: peter-evans/slash-command-dispatch@v3
id: slash-command-dispatch
with:
token: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
permission: write
issue-type: pull-request
repository: airbytehq/airbyte-platform-internal
dispatch-type: repository
static-args: |
repository=${{ needs.check.outputs.repo_full_name }}
branch=${{ needs.check.outputs.pull_request_branch }}
pr_number=${{ github.event.issue.number }}
commands: |
create-oss-pr
- name: Publish comment with requirements to update branch
if: needs.check.outputs.branch_up_to_date == 'false'
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.issue.number }}
body: |
Your branch is not currently up-to-date with `main`. Please update your branch before attempting to snapshot your PR.
- name: Publish comment with error message
if: steps.slash-command-dispatch.outputs.error-message
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ github.event.comment.id }}
body: |
> Error: ${{ steps.slash-command-dispatch.outputs.error-message }}