Skip to content

Create release PR and generate changelog #7

Create release PR and generate changelog

Create release PR and generate changelog #7

# Default based by dev branch
name: Create release PR and generate changelog
on:
workflow_dispatch:
inputs:
from-tag:
description: ''
required: false
to-tag:
description: ''
required: false
jobs:
release-pr:
name: Create release PR with changelog
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
show-progress: false
fetch-depth: 0
- name: Computed envs
run: |
echo "DATE=$(date +'%d.%m.%Y')" >> $GITHUB_ENV
echo "FROM_TAG=$(git merge-base --fork-point origin/master)" >> $GITHUB_ENV
echo "FILE=${{ github.workspace }}/changelog_artifacts.md" >> $GITHUB_ENV
- name: Build Changelog
id: github_release
uses: mikepenz/[email protected]
with:
fromTag: ${{ github.event.inputs.from-tag || env.FROM_TAG }}
toTag: ${{ github.event.inputs.to-tag }}
configuration: "./.github/changelog-builder-config.json"
- name: List pull request
# List merged pull request into dev branch
run: echo "pull_requests --> ${{ steps.github_release.outputs.pull_requests }}"
- name: Install dependencies
run: |
cd .github/actions/processing-release-changelog
npm ci
- name: Processing changelog data
id: changelog
uses: ./.github/actions/processing-release-changelog
with:
data: |
${{ steps.github_release.outputs.changelog }}
- name: Create release PR
run: |
changelog='${{ steps.changelog.outputs.changelog }}'
gh pr create --base master --head ${{ github.ref_name }} --title "Release by ${{ env.DATE }}" --body "$changelog"
- name: Processing pull request by title
id: jira_tasks
uses: actions/github-script@v7
env:
PULL_REQUESTS_IDS: ${{ steps.github_release.outputs.pull_requests }}
with:
script: |
const prIds = process.env.PULL_REQUESTS_IDS.split(',').map(id => parseInt(id));
const ids = [];
for (const prId of prIds) {
try {
const { data: pr } = await github.rest.pulls.get({
owner: 'Yakutoc',
repo: 'plasma-dev-stage',
pull_number: prId
});
const jiraIdMatch = pr.title.toLocaleLowerCase().match(/plasma-\d+/);
const id = jiraIdMatch ? jiraIdMatch[0] : null;
if (id) {
ids.push(id);
}
} catch (error) {
console.error(`Error fetching PR #${prId}:`, error);
}
}
console.log('Found pull requests:', ids);
return ids;
- name: Send MM
uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOKS_RELEASE_LF_MM }}
TEXT: |-
{
"name": "plasma",
"version": "",
"applicationType": "web",
"hotfix": false,
"authorMmUser": "alex_czech",
"configurationElement": "${{ secrets.CE }}",
"distributionLink": "https://github.com/salute-developers/plasma/pull/1487",
"tasks": ${{ steps.jira_tasks.outputs.result }},
"jiraProject": "PLASMA"
}