This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
75 lines (62 loc) · 2.91 KB
/
generate_and_push_deriv_ui.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
name: Generate and push @deriv/ui
permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
jobs:
generate_and_push_deriv_ui:
if: github.repository == 'binary-com/deriv-components'
runs-on: 'ubuntu-latest'
steps:
- name: Setup node and npm
id: step1
uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Checkout repo
id: step2
uses: actions/checkout@v3
with:
fetch-depth: 1
ref: master
- name: Bump version and create PR
id: step3
run: |
package_name="@deriv/ui"
# Identify with Git, these values come from the shared Deriv FE account. https://github.com/DerivFE
git config --global user.name "DerivFE"
git config --global user.email "[email protected]"
npm i && npm i -g json@latest
old_version=$(json -f ./package.json version)
# check if branch already exists in remote
if [ $( git ls-remote origin "$package_name" ) ]
then
# if the branch already exists delete it
git push origin -d "$package_name"
fi
git checkout -b "$package_name"
git reset --hard master
# this is a cloned repo, need to create PR to update package.json version in master
# Wait for the new version to be published
sleep 30s
npm install
# Patch the version with minor patch. It also makes a commit to the git.
npm version minor
git push --set-upstream origin "$package_name" -f
sudo apt install gh
gh auth login --with-token <<< ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# Publish to npm
npm run clean
npm run build_and_publish
new_version=$(npm show "$package_name" version)
diff_url="https://diff.intrinsic.com/$package_name/$old_version/$new_version.diff"
pr_body=$(curl $diff_url)
# Close the PR if it already exists and create a new one
gh pr close "$package_name" || true
# Create new PR with diff as body
gh pr create --title "Bump $package_name from $old_version to $new_version" --body "\`\`\`diff ${pr_body:0:5000} \`\`\` Diff url: $diff_url" --base "master" --head "binary-com:$package_name"