-
Notifications
You must be signed in to change notification settings - Fork 8
91 lines (83 loc) · 3.49 KB
/
devScriptsUpdate.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
on:
workflow_call:
secrets:
SVC_CLI_BOT_GITHUB_TOKEN:
description: A Github PAT with repo write access.
required: true
jobs:
# what is the RC version, numerically?
compareVersions:
outputs:
shouldUpdate: ${{ !endsWith(steps.packageVersion.outputs.prop, steps.version-info.outputs.version) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: salesforcecli/github-workflows/.github/actions/versionInfo@main
id: version-info
with:
version: latest
npmPackage: "@salesforce/dev-scripts"
- run: echo "dev scripts latest is ${{ steps.version-info.outputs.version }}"
- uses: notiz-dev/github-action-json-property@7a701887f4b568b23eb7b78bb0fc49aaeb1b68d3
id: packageVersion
with:
path: "package.json"
prop_path: "devDependencies.@salesforce/dev-scripts"
- run: echo "this repo has version is ${{ steps.packageVersion.outputs.prop }}"
- run: echo "output value will be ${{ !endsWith(steps.packageVersion.outputs.prop, steps.version-info.outputs.version) }}"
updateDevScripts:
needs: [compareVersions]
if: ${{ needs.compareVersions.outputs.shouldUpdate == 'true' }}
runs-on: "ubuntu-latest"
steps:
- run: echo "previous job output was ${{ needs.compareVersions.outputs.shouldUpdate }}"
- uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- name: Get Github user info
id: github-user-info
uses: salesforcecli/github-workflows/.github/actions/getGithubUserInfo@main
with:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: salesforcecli/github-workflows/.github/actions/gitConfig@main
with:
username: ${{ steps.github-user-info.outputs.username }}
email: ${{ steps.github-user-info.outputs.email }}
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
- run: npm install -g yarn-deduplicate
- run: yarn upgrade @salesforce/dev-scripts@latest
# this may fail because that's how dev-scripts does things
- run: yarn install --network-timeout 600000
continue-on-error: true
- run: yarn install --network-timeout 600000
- run: npx yarn-deduplicate
- run: yarn install --network-timeout 600000
# clean up any outstanding unmerged devScripts PRs
- run: |
PRs=$(gh pr list --search "in:title devScripts update" --json number | jq '.[] | .number' -r | tr -d '[],"')
for pr in $PRs; do
gh pr close "$pr" -c "will be replaced with new PR" --delete-branch
done
env:
GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
# this may fail but we still want a PR with partial fix
- run: |
git checkout -b devScripts$(date +%F)
yarn lint -- --fix
continue-on-error: true
- run: |
git add .
git commit -m 'chore: updates from devScripts' --no-verify
git push origin --no-verify
# sometimes pr can't create immediately
- uses: salesforcecli/github-workflows/.github/actions/retry@main
with:
max_attempts: 5
command: |
gh pr create --title 'refactor: devScripts update' --body 'created via github action [skip-validate-pr]' -l dependencies
env:
GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}