Skip to content

Commit c72841c

Browse files
committed
Adapt merge-dependabot to RTC
This PR removes the `merge-dependabot` workflow and replaces it with a new `add-dependabot-changelog` workflow that: - Runs on each push to a `dependabot/*` branch. - If the current reference is a Dependabot PR it pushes a new changelog entry to the Dependabot branch.
1 parent 1798fc2 commit c72841c

File tree

3 files changed

+118
-53
lines changed

3 files changed

+118
-53
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: add-dependabot-changelog
19+
20+
on:
21+
push:
22+
branches:
23+
- "dependabot/*"
24+
25+
permissions:
26+
contents: write
27+
28+
jobs:
29+
30+
add-changelog-entry:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
35+
- name: Fetch metadata
36+
id: dependabot-metadata
37+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # 2.3.0
38+
with:
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Find dependency attributes
42+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
43+
shell: bash
44+
env:
45+
DEPENDENCY_NAMES: ${{ steps.dependabot-metadata.outputs.dependency-names }}
46+
DEPENDENCY_VERSION: ${{ steps.dependabot-metadata.outputs.new-version }}
47+
run: |
48+
DEPENDENCY_NAME=$(echo "$DEPENDENCY_NAMES" | tr "," '\n' | head -n 1)
49+
cat >> $GITHUB_ENV << EOF
50+
DEPENDENCY_NAME=$DEPENDENCY_NAME
51+
DEPENDENCY_VERSION=$DEPENDENCY_VERSION
52+
EOF
53+
54+
- name: Checkout repository
55+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
56+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
57+
58+
- name: Set up Java & GPG
59+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
60+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # 4.7.1
61+
with:
62+
distribution: zulu
63+
java-version: 17
64+
cache: maven
65+
server-id: apache.releases.https
66+
server-username: NEXUS_USERNAME
67+
server-password: NEXUS_PASSWORD
68+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
69+
70+
- name: Find the release version major
71+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
72+
shell: bash
73+
run: |
74+
RELEASE_VERSION_MAJOR=$(./mvnw \
75+
--non-recursive --quiet --batch-mode \
76+
-DforceStdout=true \
77+
-Dexpression=parsedVersion.majorVersion \
78+
build-helper:parse-version help:evaluate \
79+
| tail -n 1)
80+
echo "RELEASE_VERSION_MAJOR=$RELEASE_VERSION_MAJOR" >> $GITHUB_ENV
81+
82+
- name: Create changelog entry
83+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
84+
shell: bash
85+
env:
86+
PR_URL: ${{ github.event.pull_request.html_url }}
87+
PR_ID: ${{ github.event.pull_request.number }}
88+
run: |
89+
if [ -d "src/changelog" ]; then
90+
RELEASE_CHANGELOG_FILEPATH="src/changelog/.${RELEASE_VERSION_MAJOR}.x.x"
91+
SAFE_DEPENDENCY_NAME=$(echo "$DEPENDENCY_NAME" | tr "[:upper:]" "[:lower:]" | sed -r 's/[^a-z0-9]/_/g' | sed -r 's/_+/_/g')
92+
CHANGELOG_ENTRY_FILEPATH="$RELEASE_CHANGELOG_FILEPATH/update_${SAFE_DEPENDENCY_NAME}.xml"
93+
mkdir -p $(dirname "$CHANGELOG_ENTRY_FILEPATH")
94+
cat > "$CHANGELOG_ENTRY_FILEPATH" << EOF
95+
<?xml version="1.0" encoding="UTF-8"?>
96+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
97+
xmlns="https://logging.apache.org/xml/ns"
98+
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
99+
type="updated">
100+
<issue id="$PR_ID" link="$PR_URL"/>
101+
<description format="asciidoc">Update \`$DEPENDENCY_NAME\` to version \`$DEPENDENCY_VERSION\`</description>
102+
</entry>
103+
EOF
104+
fi
105+
106+
- name: Add & commit changes
107+
if: ${{ steps.dependabot-metadata.outputs.dependency-names }}
108+
shell: bash
109+
env:
110+
PR_ID: ${{ github.event.pull_request.number }}
111+
PR_BRANCH: ${{ github.head_ref }}
112+
run: |
113+
git add src/changelog
114+
git config user.name "ASF Logging Services RM"
115+
git config user.email [email protected]
116+
git commit -S -a -m "Add changelog for #$PR_ID"
117+
# Push to the branch
118+
git push

.github/workflows/build.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ permissions: read-all
2929
jobs:
3030

3131
build:
32-
if: github.actor != 'dependabot[bot]'
3332
uses: apache/logging-parent/.github/workflows/build-reusable.yaml@rel/12.1.0
3433
secrets:
3534
DV_ACCESS_TOKEN: ${{ startsWith(github.ref_name, 'release/') && '' || secrets.DEVELOCITY_ACCESS_KEY }}

.github/workflows/merge-dependabot.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)