forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (87 loc) · 3.86 KB
/
changelog.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# This action requires that any PR targeting the main branch should add a
# yaml file to the ./unreleased/ directory. If a CHANGELOG entry is not required,
# or if performing maintance on the Changelog, add the "Skip Changelog" label to
# disable this action.
name: changelog
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
jobs:
changelog:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog')}}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Cache Go
id: go-cache
uses: actions/cache@v3
with:
path: |
~/go/bin
~/go/pkg/mod
key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Ensure no changes to the CHANGELOG
run: |
# Only the latest commit of the feature branch is available
# automatically. To diff with the base branch, we need to
# fetch that too (and we only need its latest commit).
git fetch origin ${{ github.base_ref }} --depth=1
if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]]
then
echo "The CHANGELOG should not be directly modified."
echo "Please add a .yaml file to the ./unreleased/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "The CHANGELOG was not modified."
fi
- name: Ensure ./unreleased/*.yaml addition(s)
run: |
git fetch origin ${{ github.base_ref }} --depth=1
if [[ 1 -gt $(git diff --diff-filter=A --name-only FETCH_HEAD ./unreleased | grep -c \\.yaml) ]]
then
echo "No changelog entry was added to the ./unreleased/ directory."
echo "Please add a .yaml file to the ./unreleased/ directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add the \"Skip Changelog\" label if this job should be skipped."
false
else
echo "A changelog entry was added to the ./unreleased/ directory!"
fi
- name: Ensure no other ./unreleased/*.yaml changes
run: |
git fetch origin ${{ github.base_ref }} --depth=1
if [[ 0 -eq $(git diff --diff-filter=CDMRTUXB --name-only FETCH_HEAD ./unreleased | grep -c \\.yaml) ]]
then
echo "No other changes to ./unreleased/ directory!"
else
echo "Unrelated changes to ./unreleased/ directory detected."
echo "Only a single file may be added to ./unreleased/ directory per PR. No other changes are allowed to this directory."
echo "See CONTRIBUTING.md for more details."
echo "Alternately, add the \"Skip Changelog\" label if this job should be skipped."
false
fi
- name: Validate ./unreleased/*.yaml changes
run: |
make chlog-validate \
|| { echo "New ./unreleased/*.yaml file failed validation."; exit 1; }
# In order to validate any links in the yaml file, render the config to markdown
- name: Render unreleased changelog entries
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Run markdown-link-check
run: |
markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
changelog_preview.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }