Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit 891838e

Browse files
Bug Fix: Moved changelog jobs into deploy prod workflow
Signed-off-by: Adroaldo Neto <adroaldo.neto@zup.com.br>
1 parent e3d2603 commit 891838e

File tree

2 files changed

+67
-67
lines changed

2 files changed

+67
-67
lines changed

.github/workflows/deploy-prod.yml

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,72 @@ on:
2121
types: [released]
2222

2323
jobs:
24-
DISPATCH_EVENT:
24+
export_properties:
25+
name: Export Properties
26+
runs-on: ubuntu-latest
27+
outputs:
28+
changelog: ${{ steps.properties.outputs.changelog }}
29+
steps:
30+
# Set environment variables
31+
- name: Export Properties
32+
id: properties
33+
run: |
34+
CHANGELOG="$(cat << 'EOM' | sed -e "/## What's Changed/d" -e 's/^[[:space:]]*$//g' -e '/./,$!d'
35+
${{ github.event.release.body }}
36+
EOM
37+
)"
38+
39+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
40+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
41+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
42+
CHANGELOG="${CHANGELOG//'**Full Changelog**'/'Full Changelog'}"
43+
44+
echo "::set-output name=changelog::$CHANGELOG"
45+
46+
changelog:
47+
name: Changelog
48+
needs:
49+
- export_properties
50+
runs-on: ubuntu-latest
51+
steps:
52+
# Check out current repository
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
with:
56+
ref: ${{ github.event.release.tag_name }}
57+
58+
# Update Unreleased section with the current release note
59+
- name: Patch Changelog
60+
if: ${{ needs.export_properties.outputs.changelog != '' }}
61+
env:
62+
CHANGELOG: ${{ needs.export_properties.outputs.changelog }}
63+
run: |
64+
./gradlew patchChangelog --release-note="$CHANGELOG"
65+
66+
# Create pull request
67+
- name: Create Pull Request
68+
if: ${{ needs.export_properties.outputs.changelog != '' }}
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.accessToken }}
71+
run: |
72+
VERSION="${{ github.event.release.tag_name }}"
73+
BRANCH="changelog-update-$VERSION"
74+
75+
git config user.email "action@github.com"
76+
git config user.name "GitHub Action"
77+
78+
git checkout -b $BRANCH
79+
git commit -asm "Changelog update - $VERSION"
80+
git push --set-upstream origin $BRANCH
81+
82+
gh pr create \
83+
--title "Changelog update - \`$VERSION\`" \
84+
--body "current pull request contains patched \`changelog.md\` file for the \`$version\` version." \
85+
--base "${{ github.event.release.target_commitish }}" \
86+
--head $BRANCH \
87+
--label ignore-for-release
88+
89+
dispatch_event:
2590
runs-on: ubuntu-latest
2691
steps:
2792
- name: Dispatch init event
@@ -39,8 +104,6 @@ jobs:
39104
"client_payload": {
40105
"ref": "${{ github.ref }}",
41106
"statuses_href": "'"$STATUSES_HREF"'",
42-
"release_body": "${{ github.event.release.body }}",
43-
"tag_name": "${{ github.event.release.tag_name }}",
44-
"target_commitish": "${{ github.event.release.target_commitish }}"
107+
"tag_name": "${{ github.event.release.tag_name }}"
45108
}
46109
}'

.github/workflows/publish-marketplace.yml

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,7 @@ concurrency:
3131
cancel-in-progress: true
3232

3333
jobs:
34-
export_properties:
35-
name: Export Properties
36-
runs-on: ubuntu-latest
37-
outputs:
38-
changelog: ${{ steps.properties.outputs.changelog }}
39-
steps:
40-
# Set environment variables
41-
- name: Export Properties
42-
id: properties
43-
run: |
44-
CHANGELOG="$(cat << 'EOM' | sed -e "/## What's Changed/d" -e 's/^[[:space:]]*$//g' -e '/./,$!d'
45-
${{ github.event.client_payload.release_body }}
46-
EOM
47-
)"
4834

49-
CHANGELOG="${CHANGELOG//'%'/'%25'}"
50-
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
51-
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
52-
CHANGELOG="${CHANGELOG//'**Full Changelog**'/'Full Changelog'}"
53-
54-
echo "::set-output name=changelog::$CHANGELOG"
5535

5636
# Prepare and publish the plugin to the Marketplace repository
5737
publish:
@@ -81,46 +61,3 @@ jobs:
8161
GITHUB_TOKEN: ${{ secrets.accessToken }}
8262
run: |
8363
gh release upload ${{ github.event.client_payload.tag_name }} ./build/distributions/*
84-
85-
changelog:
86-
name: Changelog
87-
needs:
88-
- export_properties
89-
runs-on: ubuntu-latest
90-
steps:
91-
# Check out current repository
92-
- name: Checkout
93-
uses: actions/checkout@v3
94-
with:
95-
ref: ${{ github.event.client_payload.tag_name }}
96-
97-
# Update Unreleased section with the current release note
98-
- name: Patch Changelog
99-
if: ${{ needs.EXPORT_PROPERTIES.outputs.changelog != '' }}
100-
env:
101-
CHANGELOG: ${{ needs.EXPORT_PROPERTIES.outputs.changelog }}
102-
run: |
103-
./gradlew patchChangelog --release-note="$CHANGELOG"
104-
105-
# Create pull request
106-
- name: Create Pull Request
107-
if: ${{ needs.EXPORT_PROPERTIES.outputs.changelog != '' }}
108-
env:
109-
GITHUB_TOKEN: ${{ secrets.accessToken }}
110-
run: |
111-
VERSION="${{ github.event.client_payload.tag_name }}"
112-
BRANCH="changelog-update-$VERSION"
113-
114-
git config user.email "action@github.com"
115-
git config user.name "GitHub Action"
116-
117-
git checkout -b $BRANCH
118-
git commit -asm "Changelog update - $VERSION"
119-
git push --set-upstream origin $BRANCH
120-
121-
gh pr create \
122-
--title "Changelog update - \`$VERSION\`" \
123-
--body "current pull request contains patched \`changelog.md\` file for the \`$version\` version." \
124-
--base "${{ github.event.client_payload.target_commitish }}" \
125-
--head $BRANCH \
126-
--label ignore-for-release

0 commit comments

Comments
 (0)