Skip to content

Commit

Permalink
Merge pull request #12 from KrogerWalt/DCPFS-1234/Added/Changelog_upd…
Browse files Browse the repository at this point in the history
…ater

attempt dogfooding
  • Loading branch information
KrogerWalt authored Jun 2, 2021
2 parents 201129f + 0a03eea commit f4607be
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 17 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: On PR Merge

on:
workflow_dispatch:
pull_request:
types: [closed]
branches: [main]

jobs:
Update-Changelog:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: KrogerWalt/action-get-latest-tag@v2
id: get-latest-tag

- uses: KrogerWalt/action-update-changelog@main
id: changelog-update
with:
branch_name: ${{ github.event.pull_request.head.ref }}
ticket_url_prefix: https://github.com/${{ github.repository }}/issues/
version: ${{ steps.get-latest-tag.outputs.tag }}

- name: Commit Changelog
run: |
git config --global --replace-all user.name "$GITHUB_ACTOR"
git config --global --replace-all user.email "[email protected]"
git push origin main
- name: Enable "include administrators" branch protection
uses: benjefferies/branch-protection-bot@master
if: ${{ steps.version-label.outputs.level != null && (cancelled() || failure() || success()) }} # Force to always run this step to ensure "include administrators" is always turned back on
with:
access-token: ${{ secrets.ADMIN_PAT }}
enforce_admins: true
branch: main

13 changes: 3 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ jobs:

- uses: KrogerWalt/action-get-latest-tag@v2
id: get-latest-tag
if: ${{ steps.release-label.outputs.level != null }}

- uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
if: ${{ steps.release-label.outputs.level != null }}
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}

# - name: print-changelog
# run: cat CHANGELOG.md
level: ${{ steps.release-label.outputs.level || 'patch'}}

- uses: KrogerWalt/action-update-changelog@main
id: changelog-update
Expand All @@ -43,10 +38,8 @@ jobs:
ticket_url_prefix: https://github.com/${{ github.repository }}/issues/
version: ${{ steps.bump-semver.outputs.new_version }}

# - name: print-changedlog
# run: cat CHANGELOG.md

- run: echo "${{ steps.changelog-update.outputs.change_md }}"
- name: print-changelog
run: cat CHANGELOG.md

- uses: actions-ecosystem/action-regex-match@v2
id: regex-match
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:


jobs:
release:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ will update the changelog to have a new entry like:

## Inputs

| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ------------ |
| `changelog_file` | Overrides the path to the changelog. Default is ./CHANGELOG.md | `string` | `false` | CHANGELOG.md |
| `ticket_url_prefix` | If provided, will be used to create a link for referenced issues. (Make sure to include ending slash if needed. This allows ticket to be param as well.) | `string` | `false` | `N/A` |
| `version` | The version of the release will be added above this and the other unreleased changes. If not supplied this change will be added to unreleased changes. | `string` | `false` | `N/A` |
| NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ---------------- |
| `branch_name` | Overrides the branch name to parse for the message. Default is name of current branch. | `string` | `false` | `current branch` |
| `changelog_file` | Overrides the path to the changelog. Default is ./CHANGELOG.md | `string` | `false` | CHANGELOG.md |
| `ticket_url_prefix` | If provided, will be used to create a link for referenced issues. (Make sure to include ending slash if needed. This allows ticket to be param as well.) | `string` | `false` | `N/A` |
| `version` | The version of the release will be added above this and the other unreleased changes. If not supplied this change will be added to unreleased changes. | `string` | `false` | `N/A` |


## Outputs
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: Overrides the path to the changelog.
required: false
default: "CHANGELOG.md"
branch_name:
description: If provided, will be used instead of current branch name to create message.
required: false
ticket_url_prefix:
description: If provided, will be used to create a link for referenced issues.
required: false
Expand Down
6 changes: 5 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ changelogPath=${INPUT_CHANGELOG_FILE}
urlPrefix=${INPUT_TICKET_URL_PREFIX}
version=${INPUT_VERSION}
fullDate=$(date +"%F")
branchName=$(git rev-parse --abbrev-ref HEAD)
branchName=${INPUT_BRANCH_NAME}
ticket=$(echo ${branchName} | awk -F'/' '{print($1)}')
changeType=$(echo ${branchName} | awk -F'/' '{print($2)}')
message=$(echo ${branchName} | awk -F'/' '{print($3)}' | tr '_' ' ')
Expand All @@ -19,6 +19,10 @@ if [[ -z ${version} ]]; then
exit 1
fi

if [[ -z ${branchName} ]]; then
branchName=$(git rev-parse --abbrev-ref HEAD)
fi

if [[ -n ${urlPrefix} ]]; then
ticketLine="- [${ticket}](${urlPrefix}${ticket})"
fi
Expand Down

0 comments on commit f4607be

Please sign in to comment.