-
Notifications
You must be signed in to change notification settings - Fork 377
72 lines (65 loc) · 2.51 KB
/
Copy pathchangelog-preview.yml
File metadata and controls
72 lines (65 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Changelog preview
on:
pull_request:
branches:
- main
types: [opened, synchronize]
permissions:
contents: read
pull-requests: read
jobs:
generate_changelog_preview:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 24.x ]
steps:
- uses: actions/checkout@v6
with:
ref: develop
# pulls all commits (needed for semantic release to correctly version)
fetch-depth: '0'
# pulls all tags (needed for semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
- name: Install Linux build tools
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Installation
run: yarn install --immutable
- name: Generate Changelog
id: generate_changelog
run: |
GITHUB_REF='refs/heads/develop' yarn extract-changelog
echo "Changelog script finished! Checking if there are changes..."
CHANGELOG_PREVIEW=$(cat NEXT_RELEASE_CHANGELOG.md || true)
if [[ ! -z "${CHANGELOG_PREVIEW}" ]]; then
echo "Changelog found! Writing header to the file..."
echo '# Next releases' | cat - NEXT_RELEASE_CHANGELOG.md > NEXT_RELEASE_CHANGELOG.tmp.md && mv NEXT_RELEASE_CHANGELOG.tmp.md NEXT_RELEASE_CHANGELOG.md
echo "Changelog file ready! Setting up outputs"
CHANGELOG_PREVIEW=$(cat NEXT_RELEASE_CHANGELOG.md)
echo "exists=true" >> "$GITHUB_OUTPUT"
{
echo "preview<<CHANGELOG_PREVIEW_EOF"
echo "$CHANGELOG_PREVIEW"
echo "CHANGELOG_PREVIEW_EOF"
} >> "$GITHUB_OUTPUT"
fi
- uses: marocchino/sticky-pull-request-comment@v3
if: steps.generate_changelog.outputs.exists == 'true'
with:
header: changelog_preview
message: ${{ steps.generate_changelog.outputs.preview }}
- uses: marocchino/sticky-pull-request-comment@v3
if: steps.generate_changelog.outputs.exists != 'true'
with:
header: changelog_preview
message: No changelog generated for the current changes on this pull request.