-
Notifications
You must be signed in to change notification settings - Fork 4
82 lines (71 loc) · 2.97 KB
/
check_for_release.yaml
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
name: Check for new release
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
jobs:
check_for_release:
name: Check For Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for appVersion changes
run: |
echo "Checking for appVersion changes..."
if git diff origin/${{ github.base_ref }} -- deployments/chart/Chart.yaml | grep -qe "^[+-]appVersion: "; then
app_version_change=$(echo "version changed")
echo "app_version_change=$app_version_change" >> $GITHUB_ENV
else
app_version_change=$(echo "No appVersion changes detected.")
echo "app_version_change=$app_version_change" >> $GITHUB_ENV
fi
- name: Remove new version label
if: ${{ env.app_version_change == 'No appVersion changes detected.' }}
run: |
echo "No appVersion changes detected. Removing new version label"
gh pr edit ${{ github.event.pull_request.number }} --remove-label "new release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail if changes occured
if: ${{ !contains(github.event.pull_request.labels.*.name, 'new release') }}
run: |
if [ "${{ env.app_version_change }}" == "version changed" ]; then
gh pr edit ${{ github.event.pull_request.number }} --add-label "needs approval"
echo "Version changed, exiting..."
exit 1
else
echo "No appVersion changes detected."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove approval label
run: |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "needs approval"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
post_message:
name: Post Message To Warn Of New Release
runs-on: ubuntu-latest
needs: check_for_release
if: ${{ failure() && !contains(github.event.pull_request.labels.*.name, 'needs approval') && github.event.action != 'labeled' && github.event.action != 'unlabeled' }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract appVersion
id: extract_appversion
run: |
appversion=$(yq e '.appVersion' ./deployments/chart/Chart.yaml)
echo "appversion=$appversion" >> $GITHUB_ENV
- name: Post warning comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: "⚠️ Warning: Merging this PR will result in a new release because the `appVersion` in Chart.yaml has changed to `${{ env.appversion }}`. Please confirm this by adding the `new release` label before merging."