-
Notifications
You must be signed in to change notification settings - Fork 47
87 lines (73 loc) · 2.56 KB
/
auto-cl-update-atd.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
name: Auto CL update
on:
push:
branches:
- master
permissions:
contents: write
pull-requests: write
jobs:
post_merge_job:
name: Auto CL update
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Pull latest changes for update-changelog branch
run: |
git fetch origin
git checkout -B update-changelog origin/update-changelog || git checkout -b update-changelog
git pull origin update-changelog --rebase
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install requirements
run: pip install requests pyyaml
- name: Run post-merge script
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python Tools/ATD/auto_cl.py "${{ env.GITHUB_TOKEN }}" "${{ github.repository }}"
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit changes
id: commit-changes
run: |
git add .
git diff-index --quiet HEAD || git commit -m "Auto cl update"
continue-on-error: true
- name: Merge changes with ours strategy
if: steps.commit-changes.outcome == 'success'
run: |
git merge -X ours origin/update-changelog || echo "No changes to merge"
- name: Push changes to a new branch
if: steps.commit-changes.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} update-changelog --force
- name: Check if Pull Request exists
id: pr-check
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:update-changelog`
});
return pullRequests.length > 0;
- name: Create Pull Request
if: steps.commit-changes.outcome == 'success' && steps.pr-check.outputs.result == 'false'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-changelog
commit-message: "Auto cl update"
title: "Auto CL update"
body: "This PR updates the changelog."
labels: "auto-update, changelog"