-
-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (70 loc) · 2.77 KB
/
weblate-create-pr.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
68
69
70
71
on:
push:
branches:
- 'translations'
workflow_dispatch:
jobs:
create-pull-request:
permissions:
pull-requests: write
checks: write
issues: write
runs-on: ubuntu-latest
outputs:
create-pr: ${{ steps.create-pr.outputs.result }}
steps:
- name: Create Pull Request
id: create-pr
uses: actions/github-script@v7
with:
script: |
const translationsOwner = "metabrainz"
console.log(context)
const { repo, owner } = context.repo;
const { sha } = context;
const { head, base } = { base: "main", head: translationsOwner + ":translations", }
if (owner != translationsOwner) {
return
}
const main =
await github.rest.repos.getBranch({
owner,
repo,
branch: "main"
});
if (sha == main.data.commit.sha) {
return
}
const pulls = await github.rest.pulls.list({ owner, repo, head, base, state: "open" })
console.log(pulls.data)
if (pulls.data.length == 0) {
console.log("Creating PR!")
const result = await github.rest.pulls.create({
title: 'chore(translations): Update translations',
owner,
repo,
head,
base,
body: [
'**This PR is auto-generated**',
'',
'When adding a new language, please make sure to add the language to Cargo.toml',
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['translations']
});
return "created-pr"
} else {
console.log("PR exists, skipping!")
}
test:
uses: ./.github/workflows/ci.yml
permissions:
checks: write
issues: write
needs: create-pull-request
if: needs.create-pull-request.outputs.create-pr == 'created-pr'