Skip to content

Commit 06fbda8

Browse files
authored
Updating PR sync to notify our backend repo (#10)
## Summary: Updating the backend workflow sync to work with our repository. I changed it to fire only when PRs are merged to our main branch. Also fixing the slack notify action. Issue: https://khanacademy.atlassian.net/browse/DI-529 ## Test plan: - will test it after backend change merged (no way to target non-default branch): Khan/label-studio#4 Author: lizfaubell Reviewers: jimmykodes, dat-boris Required Reviewers: Approved By: jimmykodes Checks: ⏭ Coverage, ❌ Tests / E2E Tests, ✅ Build JS Bundle / Build, ✅ Lint / Run ESLint, ✅ Tests / Unit Tests, ✅ Build JS Bundle / Build Coverage, ⏭ Coverage, ⏭ Tests, ⏭ Lint, ⏭ Build JS Bundle, ⏭ Build JS Bundle, ⏭ Tests Pull Request URL: #10
1 parent 0119e31 commit 06fbda8

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.github/actions/notify_slack/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Notify Slack on workflow failure
22
description: notifies infrastructure-data-alerts channel on workflow failure.
33

4+
inputs:
5+
webhook_url:
6+
description: "Slack webhook url"
7+
required: true
8+
49
runs:
510
using: "composite"
611
steps:
@@ -17,4 +22,4 @@ runs:
1722
}
1823
env:
1924
# Notifies the #infrastructure-data-alerts channel.
20-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
25+
SLACK_WEBHOOK_URL: ${{ inputs.webhook_url }}

.github/workflows/sync-pr-ls.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
name: Sync PR LS
1+
name: Sync merged PR to Label Studio backend
22

33
on:
44
pull_request_target:
55
types:
6-
- opened
76
- closed
8-
- converted_to_draft
9-
- ready_for_review
10-
- synchronize
117
branches:
128
- master
13-
- 'ls-release/**'
149

1510
concurrency:
1611
group: ${{ github.workflow }}-${{ github.head_ref }}
@@ -21,7 +16,7 @@ env:
2116
jobs:
2217
sync:
2318
name: "Sync"
24-
if: startsWith(github.head_ref, 'fb-')
19+
if: ${{ github.event.pull_request.merged }} == true
2520
runs-on: ubuntu-latest
2621
steps:
2722
- uses: hmarr/debug-action@v2.1.0
@@ -32,16 +27,14 @@ jobs:
3227
env:
3328
TITLE: ${{ github.event.pull_request.title }}
3429
with:
35-
github-token: ${{ secrets.GIT_PAT }}
30+
github-token: ${{ secrets.KHAN_ACTIONS_BOT_TOKEN }}
3631
script: |
3732
const { repo, owner } = context.repo;
3833
const [pr_owner, pr_repo] = '${{ github.event.pull_request.head.repo.full_name || github.repository }}'.split('/');
3934
let event_action = '${{ github.event.action }}'
4035
let commit_sha = '${{ github.event.pull_request.head.sha }}'
41-
if (${{ github.event.pull_request.merged }}) {
42-
event_action = 'merged'
43-
commit_sha = '${{ github.sha }}'
44-
}
36+
event_action = 'merged'
37+
commit_sha = '${{ github.sha }}'
4538
const getCommitResponse = await github.rest.repos.getCommit({
4639
owner: pr_owner,
4740
repo: pr_repo,

.github/workflows/sync_to_release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ jobs:
2727
git merge origin/master --no-edit -m 'Merge master into release branch in run id ${{github.run_id}}'
2828
git push
2929
- name: Notify Slack on failure
30-
uses: ./.github/actions/notify_slack
30+
if: failure()
31+
uses: ./.github/actions/notify_slack
32+
with:
33+
webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)