-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (88 loc) · 3.52 KB
/
init.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
92
name: "Start using renovate"
run-name: "Start using renovate in bettermarks/${{ inputs.repository }}"
on:
workflow_dispatch:
inputs:
repository:
description: "The bettermarks repository to start using renovate in, no need to add 'bettermarks/' prefix."
required: true
type: string
javascript:
description: "Is the repository using javascript/typescript dependencies (e.g. for infrastructure as code)?"
default: true
type: boolean
python:
description: "Is the repository using python dependencies? (experimental!)"
default: false
type: boolean
secrets:
description: "Is the repository using private npm packages in the `@bettermarks/` scope?"
type: boolean
default: false
automerge:
description: "Should some dependency updates be merged a human review? Leave the field empty if you are not sure!"
default: ""
type: choice
options:
- ""
- ":automergeStableNonMajor"
- ":automergePatch"
force:
description: "Should existing config files be overwritten? If not existing files will not be modified."
type: boolean
default: false
env:
BRANCH_NAME: renovate/reconfigure
jobs:
init:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: renovate-config
- uses: actions/checkout@v4
with:
repository: bettermarks/${{ inputs.repository}}
path: ${{ inputs.repository }}
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version-file: renovate-config/.nvmrc
- working-directory: ${{ inputs.repository }}
name: "create or checkout branch ${{ env.BRANCH_NAME }}"
run: |
git switch -c $BRANCH_NAME --track origin/$BRANCH_NAME || git switch -c $BRANCH_NAME
mkdir -p .github/workflows
- working-directory: renovate-config
name: "add or update config files"
run: |
node ./init.js "../${{ inputs.repository}}" '${{ toJson(inputs) }}'
- working-directory: ${{ inputs.repository }}
name: "Commit and push changes"
run: |
git config user.name github-actions
git config user.email [email protected]
git add .github/workflows/renovate-config-validator.yml .npmrc renovate.json
(git commit -m 'chore: Automate dependency updates using renovate' || echo "nothing changed")
git push --set-upstream origin $BRANCH_NAME
- working-directory: ${{ inputs.repository }}
name: "Create pull request"
if: ${{ ! inputs.force }} # it is likely that the PR already exists when forcing
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh pr create \
--title 'chore: Automate dependency updates using renovate' \
--body 'Created by @${{ github.actor }} using https://github.com/bettermarks/renovate-config/actions/workflows/init.yml' \
--reviewer ${{ github.actor }}
- working-directory: ${{ inputs.repository }}
name: "Summary"
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh pr view --json number,title,url --template '[\#{{.number}} {{.title}}]({{.url}})
' >> $GITHUB_STEP_SUMMARY
echo '```patch' >> $GITHUB_STEP_SUMMARY
gh pr diff --patch >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY