-
Notifications
You must be signed in to change notification settings - Fork 27
108 lines (91 loc) · 3.7 KB
/
e2e-examples.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
96
97
98
99
100
101
102
103
104
105
106
107
108
name: e2e-examples
on:
pull_request:
branches:
- '**'
repository_dispatch:
types: [trigger-workflow]
jobs:
test-docs:
runs-on: ubuntu-latest
strategy:
matrix:
file-path:
- vcluster/deploy/topologies/multi-namespace-mode.mdx
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Runme CLI
run: npm install -g runme
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
- name: Check if version is provided
id: check-version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
echo "Version not provided"
echo "run-list-releases=true" >> $GITHUB_ENV
else
echo "Version provided: ${{ github.event.inputs.version }}"
echo "run-list-releases=false" >> $GITHUB_ENV
fi
- name: List releases of another repository
id: list-releases
if: env.run-list-releases == 'true'
uses: actions/github-script@v7
with:
script: |
const owner = 'loft-sh';
const repo = 'vcluster';
// Fetch all releases including pre-releases
const releases = await github.rest.repos.listReleases({
owner: owner,
repo: repo
});
// Function to compare version strings
function compareVersions(v1, v2) {
const v1parts = v1.replace(/^v/, '').split('.').map(Number);
const v2parts = v2.replace(/^v/, '').split('.').map(Number);
for (let i = 0; i < Math.max(v1parts.length, v2parts.length); i++) {
if ((v1parts[i] || 0) > (v2parts[i] || 0)) return 1;
if ((v1parts[i] || 0) < (v2parts[i] || 0)) return -1;
}
return 0;
}
// Filter and find the latest release or pre-release with version > 0.19
const minVersion = '0.19.0';
const latestRelease = releases.data
.filter(release => compareVersions(release.tag_name, minVersion) > 0)
.sort((a, b) => compareVersions(b.tag_name, a.tag_name))[0];
if (latestRelease) {
console.log(`Latest release found: ${latestRelease.tag_name}`);
core.setOutput('latest-release', latestRelease.tag_name);
} else {
console.log('No release found with version > 0.19');
core.setOutput('latest-release', '');
}
- name: Display latest release
if: env.run-list-releases == 'true'
run: |
echo "Latest vcluster release: ${{ steps.list-releases.outputs.latest-release }}"
- name: Install vcluster CLI
run: |
version=${{ github.event.inputs.version || steps.list-releases.outputs.latest-release }}
curl -LO "https://github.com/loft-sh/vcluster/releases/download/${version}/vcluster-linux-amd64"
chmod +x ./vcluster-linux-amd64
sudo mv ./vcluster-linux-amd64 /usr/local/bin/vcluster
- name: Set up kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Run documentation tests with Runme
run: |
runme run -a --skip-prompts --filename ${{ matrix.file-path }}