78 lines (74 loc) 路 3.07 KB
/
update-compat-data.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
72
73
74
75
76
name: Update compat data
env:
YARN_ENABLE_SCRIPTS: false # disable post-install scripts
on:
workflow_dispatch:
inputs: {}
schedule:
- cron: "0 0 * * 5"
jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: kangax/compat-table
path: packages/babel-compat-data/build/compat-table
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "*"
- name: Get latest kangax/compat-data commit
id: lastCommit
run: echo "::set-output name=sha1::$(node ./scripts/update-compat-data/get-last-commit.sh)"
- name: Compare last kangax/compat-data commit with current one
run: echo ${{ steps.lastCommit.outputs.sha1 }} | node ./scripts/update-compat-data/compare-with-current-commit.js
- name: Update compat-data commit
run: echo ${{ steps.lastCommit.outputs.sha1 }} | ./scripts/update-compat-data/bump-data-compat-version.sh
- name: Run update script
run: make build-compat-data
- name: Commit changes
run: |
git config user.name "Babel Bot"
git config user.email "babel-bot@users.noreply.github.com"
git checkout -b update-compat-data
git commit -am "chore: update compat data to ${{ steps.lastCommit.outputs.sha1 }}"
git push --force origin update-compat-data
- name: Create Pull Request
uses: actions/github-script@v4
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const base = process.env.GITHUB_REF.replace("refs/heads/", "");
const requestParam = {
owner: context.repo.owner,
repo: context.repo.repo,
head: context.repo.owner + ":update-compat-data",
base: base,
state: "open"
};
const result = await github.pulls.list(requestParam);
console.log("Open PR request: ", requestParam);
console.log("Open PR response: ", result);
const prs = result.data;
if (prs.length === 0) {
const requestParam = {
owner: context.repo.owner,
repo: context.repo.repo,
head: "update-compat-data",
base: base,
maintainer_can_modify: true,
title: "Update compat data",
body: "Update compat data to [${{ steps.lastCommit.outputs.sha1 }}](https://github.com/kangax/compat-table/commit/${{ steps.lastCommit.outputs.sha1 }}).",
};
const result = await github.pulls.create(requestParam);
console.log("Create PR request: ", requestParam)
console.log("Create PR response: ", result);
github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: result.data.number,
labels: ["area: compat-data", "repo automation :robot:"]
})
}