forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (66 loc) · 2.96 KB
/
post-merge.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
name: Post-merge
on:
pull_request_target:
branches:
- dev-2.x
types: [closed]
jobs:
changelog-entry:
if: github.event.pull_request.merged && github.repository_owner == 'leonardehrenfried'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Configure git user
run: |
git config --global user.name 'OTP Changelog Bot'
git config --global user.email '[email protected]'
- name: Generate changelog entry from PR information
run: |
# if the title contains "changelog skip" we don't generate an entry
TITLE_LOWER_CASE=`echo $TITLE | awk '{print tolower($0)}'`
if [[ "${TITLE_LOWER_CASE}" =~ "changelog skip" ]]; then
echo "Skipping changelog entry generation"
else
# add a line above the one which contains AUTOMATIC_CHANGELOG_PLACEHOLDER
ITEM="${TITLE} [#${NUMBER}](${URL})"
TEMP_FILE=docs/Changelog.generated.md
FILE=docs/Changelog.md
awk "/CHANGELOG_PLACEHOLDER/{print \"- $ITEM\"}1" $FILE > $TEMP_FILE
mv $TEMP_FILE $FILE
git add $FILE
git commit -m "Add changelog entry for #${NUMBER} [ci skip]"
git push origin HEAD:dev-2.x
fi
env:
# Use environment variables to prevent injection attack
TITLE: ${{ github.event.pull_request.title }}
NUMBER: ${{ github.event.pull_request.number }}
URL: ${{ github.event.pull_request.html_url }}
serialization-version:
if: github.event.pull_request.merged && github.repository_owner == 'leonardehrenfried' && contains(github.event.pull_request.labels.*.name, 'bump serialization version')
runs-on: ubuntu-latest
needs: [changelog-entry]
steps:
- name: Install xmllint
run: |
sudo apt-get install -y libxml2-utils
- name: Configure git user
run: |
git config --global user.name 'OTP Serialization Version Bot'
git config --global user.email '[email protected]'
- name: Checkout
uses: actions/checkout@v2
- name: Bump serialization version
run: |
version=`xmllint --xpath "//*[local-name()='otp.serialization.version.id']/text()" pom.xml`
bumped=$((version+1))
sed -Ei "s/<otp\.serialization\.version\.id>.*<\/otp\.serialization\.version\.id>/<otp\.serialization\.version\.id>${bumped}<\/otp\.serialization\.version\.id>/" pom.xml
git add pom.xml
git commit -m "Bumping serialization version id for #${NUMBER}"
# just for safety as the git repo can be eventually consistent and this push competes with the changelog entry
git pull --rebase origin dev-2.x
git push origin HEAD:dev-2.x
env:
# Use environment variables to prevent injection attack
NUMBER: ${{ github.event.pull_request.number }}