Skip to content

Commit

Permalink
Add changelog.txt update workflow (woocommerce#34554)
Browse files Browse the repository at this point in the history
  • Loading branch information
roykho authored Sep 7, 2022
1 parent a197622 commit 4e2ac1f
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Run post release processes
on:
release:
types: [released]

env:
GIT_COMMITTER_NAME: 'WooCommerce Bot'
GIT_COMMITTER_EMAIL: 'no-reply@woocommerce.com'
GIT_AUTHOR_NAME: 'WooCommerce Bot'
GIT_AUTHOR_EMAIL: 'no-reply@woocommerce.com'

jobs:
update-changelog-in-trunk:
name: Update changelog in trunk
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Get tag name
id: tag
uses: actions/github-script@v6
with:
script: |
const tag = ${{ toJSON( github.event.release.tag_name ) }}
console.log( `::set-output name=tag::release/${ tag.substring( 0, 3 ) }` )
- name: Git fetch trunk branch
run: git fetch origin trunk

- name: Copy changelog.txt to vm root
run: cp changelog.txt ../../changelog.txt

- name: Switch to trunk branch
run: git checkout trunk

- name: Create a new branch based on trunk
run: git checkout -b update/changelog-from-release-${{ github.event.release.tag_name }}

- name: Copy saved changelog.txt to monorepo
run: cp ../../changelog.txt ./changelog.txt

- name: Commit changes
run: git commit -am "Update changelog.txt from release ${{ github.event.release.tag_name }}"

- name: Push branch up
run: git push origin update/changelog-from-release-${{ github.event.release.tag_name }}

- name: Create the PR
uses: actions/github-script@v6
with:
script: |
const body = "This PR updates the changelog.txt based on the latest release: ${{ github.event.release.tag_name }}"
const pr = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Update changelog.txt from release ${{ github.event.release.tag_name }}",
head: "update/changelog-from-release-${{ github.event.release.tag_name }}",
base: "trunk",
body: body
})
const prCreated = await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.data.number,
reviewers: ["${{ github.event.release.author.login }}"]
})

0 comments on commit 4e2ac1f

Please sign in to comment.