-
Notifications
You must be signed in to change notification settings - Fork 32
99 lines (87 loc) · 2.89 KB
/
update_changelog.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
93
94
95
96
97
98
99
name: Update Changelog
on:
release:
types: [published]
push:
branches:
- main # or your default branch name
pull_request:
branches:
- main # or your default branch name
jobs:
test-changelog-update:
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests python-dotenv semver
- name: Test Changelog Update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x # Enable verbose output
echo "Configuring Git..."
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
echo "Current directory and files:"
pwd
ls -la
echo "Git status and branch:"
git status
git branch
echo "GitHub event name: ${{ github.event_name }}"
echo "GitHub head ref: ${{ github.head_ref }}"
echo "GitHub ref name: ${{ github.ref_name }}"
echo "Checking out correct branch..."
if [ "${{ github.event_name }}" = "pull_request" ]; then
git checkout -b "${{ github.head_ref }}" || echo "Failed to create new branch"
else
git checkout "${{ github.ref_name }}" || echo "Failed to checkout branch"
fi
echo "Current branch after checkout:"
git branch
echo "Running update script..."
python update_changelog.py
echo "Checking for changes..."
git add docs/changelog.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
echo "Changes detected, committing..."
git commit -m "Update changelog for latest release"
echo "Pushing changes..."
git push origin HEAD:"${{ github.head_ref || github.ref_name }}" || echo "Failed to push changes"
fi
echo "Final Git status:"
git status
update-changelog:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests python-dotenv
- name: Update Changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python update_changelog.py
- name: Commit changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add docs/changelog.md
git commit -m "Update changelog for latest release" || echo "No changes to commit"
git push