Skip to content

Commit

Permalink
Add changelog auto update github action (#11)
Browse files Browse the repository at this point in the history
This workflow will copy changelog from release
branch to main branch after release is triggered.

Signed-off-by: Rahul Jain <rahulj@vmware.com>
  • Loading branch information
reachjainrahul committed Aug 24, 2022
1 parent fbb4dbb commit b8b3629
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/update_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update CHANGELOG after release

on:
push:
tags:
- v*

jobs:
check-version:
runs-on: [ubuntu-latest]
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Extract version from Github ref
id: get-version
env:
TAG: ${{ github.ref }}
shell: bash
run: |
version=${TAG:10}
if [[ "$version" == *-* ]]; then
echo "$version is a release candidate or a pre-release"
exit 0
fi
echo "::set-output name=version::$version"
pr-update-changelog:
runs-on: [ubuntu-latest]
needs: check-version
if: ${{ needs.check-version.outputs.version != '' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Cherry-pick changelog commit
env:
VERSION: ${{ needs.check-version.outputs.version }}
shell: bash
run: |
git config user.name github-actions
git config user.email github-actions@github.com
commit_hash=$(git log "$VERSION" --format="%H" --grep="Update CHANGELOG for $VERSION release")
if [[ -z "$commit_hash" ]]; then
echo "Cannot find commit"
exit 1
fi
git cherry-pick "$commit_hash"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.ANTREA_BOT_WRITE_PAT }}
delete-branch: true
title: "Update CHANGELOG for ${{ needs.check-version.outputs.version }} release"
body: |
PR was opened automatically from Github Actions
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 comments on commit b8b3629

Please sign in to comment.