woocommerce/.github/workflows/post-release.yml

69 lines
2.3 KiB
YAML
Raw Normal View History

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 }}"]
})