-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (110 loc) · 3.95 KB
/
Copy pathpull_request.yml
File metadata and controls
118 lines (110 loc) · 3.95 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Pull Request Go Releaser
on:
pull_request:
push:
branches:
- main
permissions:
checks: write
jobs:
validate-chart-version:
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check if chart files changed
id: check-chart-changes
run: |
git fetch origin main:main
if git diff --name-only origin/main...HEAD | grep -q '^chart/'; then
echo "chart-changed=true" >> "$GITHUB_OUTPUT"
else
echo "chart-changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Get current chart version
id: current-version
if: steps.check-chart-changes.outputs.chart-changed == 'true'
run: |
current_version=$(grep '^version:' chart/cert-manager-webhook-ionos-cloud/Chart.yaml | awk '{print $2}')
echo "current-version=$current_version" >> "$GITHUB_OUTPUT"
- name: Get main branch chart version
id: main-version
if: steps.check-chart-changes.outputs.chart-changed == 'true'
run: |
git checkout main
main_version=$(grep '^version:' chart/cert-manager-webhook-ionos-cloud/Chart.yaml | awk '{print $2}')
echo "main-version=$main_version" >> "$GITHUB_OUTPUT"
git checkout -
- name: Validate version bump
if: steps.check-chart-changes.outputs.chart-changed == 'true'
run: |
current="${{ steps.current-version.outputs.current-version }}"
main="${{ steps.main-version.outputs.main-version }}"
echo "Current chart version: $current"
echo "Main branch chart version: $main"
if [ "$current" = "$main" ]; then
echo "❌ Chart files were modified but chart version was not bumped!"
echo "Please increment the version in chart/cert-manager-webhook-ionos-cloud/Chart.yaml"
echo "Current version: $current"
exit 1
else
echo "✅ Chart version was properly bumped from $main to $current"
fi
snapshot-release:
runs-on: ubuntu-22.04
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Git Fetch
run: git fetch --force --tags
- name: Get latest non-chart tag
id: get-latest-release-tag
run: |
latest_release_tag="$(git tag --list --sort='-version:refname' | grep -v 'chart' | head -n 1)"
echo "latest-release-tag=$latest_release_tag" >> "$GITHUB_OUTPUT"
echo "Using release tag: $latest_release_tag"
- name: Setup go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Run Unit Tests
run: make unit-test
- name: Test Report
uses: dorny/test-reporter@v3
if: success() || failure()
with:
name: Unit Test Results
path: ./out/report.xml
reporter: java-junit
fail-on-error: 'true'
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-test-reports
path: ./out/report.xml
- name: Run conformance tests
env:
TEST_ZONE_NAME: ${{ secrets.TEST_ZONE_NAME }}
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN }}
run: |
make conformance-test
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Go Snapshot Release
if: github.event_name == 'pull_request'
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: v2.9.0
args: release --snapshot --clean --skip=publish
env:
GORELEASER_CURRENT_TAG: ${{ steps.get-latest-release-tag.outputs.latest-release-tag }}