-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (56 loc) · 1.63 KB
/
update.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
name: Update cargo lockfile
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
check-update:
runs-on: ubuntu-latest
outputs:
has_diff: ${{ steps.check-diff.outputs.has_diff }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update
run: cargo update
- name: Check diff
id: check-diff
run: |
if git diff --exit-code Cargo.lock > /dev/null; then
echo "has_diff=false" >> "$GITHUB_OUTPUT"
else
echo "has_diff=true" >> "$GITHUB_OUTPUT"
fi
update-lockfile:
runs-on: ubuntu-latest
needs: check-update
# いつforkされてもいいように
if: >-
needs.check-update.outputs.has_diff == 'true' && (
github.repository_owner == 'H1rono' ||
github.repository_owner == 'h1rono'
)
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update
run: cargo update
- name: git commit and push
run: |
git config user.name "H1rono"
git config user.email "[email protected]"
BRANCH_NAME="update-$(date +'%Y%m%d%H%M%S')"
git switch -c "$BRANCH_NAME"
git add Cargo.lock
git commit -m ":arrow_up: CI: update lockfile"
git push origin "$BRANCH_NAME"
- name: Create pull request
run: |
gh pr create --title ":arrow_up: CI: update lockfile" --body "" --base main --assignee H1rono
env:
GH_TOKEN: ${{ secrets.PAT }}