-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (86 loc) · 4.86 KB
/
update-depend-versions.yaml
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
93
94
95
96
97
98
99
100
name: update-depend-versions
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
update-depend-versions:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
- name: Check out repository
uses: actions/checkout@v3
- name: Set up sd
uses: kenji-miyake/setup-sd@v1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Get flake8 versions
id: get-flake8-versions
run: |
function get-latest-pip-version() {
pip index versions "$1" 2>/dev/null | head -n1 | sd '.*\((.*)\)' '$1'
}
echo ::set-output name=flake8-version::$(get-latest-pip-version flake8)
echo ::set-output name=flake8-blind-except-version::$(get-latest-pip-version flake8-blind-except)
echo ::set-output name=flake8-builtins-version::$(get-latest-pip-version flake8-builtins)
echo ::set-output name=flake8-class-newline-version::$(get-latest-pip-version flake8-class-newline)
echo ::set-output name=flake8-comprehensions-version::$(get-latest-pip-version flake8-comprehensions)
echo ::set-output name=flake8-deprecated-version::$(get-latest-pip-version flake8-deprecated)
echo ::set-output name=flake8-docstrings-version::$(get-latest-pip-version flake8-docstrings)
echo ::set-output name=flake8-import-order-version::$(get-latest-pip-version flake8-import-order)
echo ::set-output name=flake8-quotes-version::$(get-latest-pip-version flake8-quotes)
- name: Update flake8 version
run: |
sd '(flake8)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-version }}' .pre-commit-hooks.yaml
sd '(flake8-blind-except)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-blind-except-version }}' .pre-commit-hooks.yaml
sd '(flake8-builtins)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-builtins-version }}' .pre-commit-hooks.yaml
sd '(flake8-class-newline)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-class-newline-version }}' .pre-commit-hooks.yaml
sd '(flake8-comprehensions)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-comprehensions-version }}' .pre-commit-hooks.yaml
sd '(flake8-deprecated)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-deprecated-version }}' .pre-commit-hooks.yaml
sd '(flake8-docstrings)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-docstrings-version }}' .pre-commit-hooks.yaml
sd '(flake8-import-order)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-import-order-version }}' .pre-commit-hooks.yaml
sd '(flake8-quotes)==\d+\.\d+(\.\d+)?' '$1==${{ steps.get-flake8-versions.outputs.flake8-quotes-version }}' .pre-commit-hooks.yaml
- name: Get prettier versions
id: get-prettier-versions
run: |
function get-latest-npm-version() {
npm show "$1" version
}
echo ::set-output name=prettier-version::$(get-latest-npm-version prettier)
echo ::set-output name=prettier-xml-version::$(get-latest-npm-version @prettier/plugin-xml)
- name: Update prettier version
run: |
sd '(prettier)@\d+\.\d+\.\d+' '$1@${{ steps.get-prettier-versions.outputs.prettier-version }}' .pre-commit-hooks.yaml
sd '(@prettier/plugin-xml)@\d+\.\d+\.\d+' '$1@${{ steps.get-prettier-versions.outputs.prettier-xml-version }}' .pre-commit-hooks.yaml
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
base: ${{ github.event.repository.default_branch }}
branch: update-depend-versions
title: "chore: update depend versions"
commit-message: "chore: update depend versions"
body: ""
labels: |
bot
update-depend-versions
signoff: true
delete-branch: true
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}"
shell: bash
- name: Enable auto-merge
if: ${{ steps.create-pr.outputs.pull-request-operation == 'created' }}
run: gh pr merge --squash --auto "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}