-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1012 from ErikJiang/update_spray_artifact_patch_ci
update kubespray artifact patch CI
- Loading branch information
Showing
3 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,7 +189,8 @@ jobs: | |
mkdir manifest && cp charts/kubean/templates/manifest.cr.yaml manifest/manifest-${{ needs.check-inputs.outputs.tag }}.yml | ||
echo "manifest cr output:" | ||
cat manifest/manifest-${{ needs.check-inputs.outputs.tag }}.yml | ||
rm -rf kubespray/ | ||
- name: Push Kubean manifest to another repository | ||
env: | ||
REPO_OWNER: ${{ github.repository_owner }} | ||
|
@@ -198,6 +199,26 @@ jobs: | |
run: | | ||
./hack/sync-manifest.sh | ||
- name: Generate artifacts patch markdown doc | ||
env: | ||
IMAGE_REPO: ${{ needs.check-inputs.outputs.image_repo }} | ||
run: | | ||
python artifacts/gen_artifact_patch_md.py | ||
mv artifacts.md docs/overrides/artifacts.md | ||
- name: Push artifact patch md | ||
id: push_directory | ||
uses: cpina/[email protected] | ||
env: | ||
SSH_DEPLOY_KEY: ${{ secrets.SYNC_RLS_PRIVATE_KEY }} | ||
with: | ||
source-directory: . | ||
destination-github-username: ${{ github.repository_owner }} | ||
destination-repository-name: kubean | ||
user-email: kubean-robot@kubean-io | ||
commit-message: Update artifacts.md, See ORIGIN_COMMIT from $GITHUB_REF | ||
target-branch: main | ||
|
||
show-artifacts: | ||
needs: [check-inputs, build-kubespray-image, build-sprayjob-image, build-airgap-patch-image, gen-manifest] | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python | ||
|
||
import subprocess | ||
import yaml | ||
import os | ||
from jinja2 import Template | ||
from datetime import datetime | ||
|
||
IMAGE_REPO = os.getenv("IMAGE_REPO", default="kubean-io") | ||
|
||
KUBEAN_PATCH_TEMPLATE = ''' | ||
{% for release, infos in releases.items() %} | ||
### ▶️ release-{{ release }} | ||
> ⚓ kube_version range: [ {{ infos[0].kube_version_range[infos[0].kube_version_range|length-1] }} ~ {{ infos[0].kube_version_range[0] }} ] | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Commit Date</th> | ||
<th>Artifacts</th> | ||
</tr> | ||
</thead> | ||
{% for info in infos %} | ||
<tbody> | ||
<tr> | ||
<td rowspan=3> 📅 {{ info.commit_date }} </td> | ||
<td rowspan=1> | ||
📝 <a href="https://raw.githubusercontent.com/{{ repo_name }}/kubean-manifest/main/manifests/manifest-{{ release }}-{{ info.commit_short_sha }}.yml">manifest-{{ release }}-{{ info.commit_short_sha }}.yml</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td rowspan=1> 📦 {{ image_registry }}/{{ repo_name }}/spray-job:{{ release }}-{{ info.commit_short_sha }} </td> | ||
</tr> | ||
<tr> | ||
<td rowspan=1> 📦 {{ image_registry }}/{{ repo_name }}/airgap-patch:{{ release }}-{{ info.commit_short_sha }} </td> | ||
</tr> | ||
</tbody> | ||
{% endfor %} | ||
</table> | ||
{% endfor %} | ||
''' | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
repo_name="kubean-manifest" | ||
subprocess.getoutput(f"git clone https://github.com/{IMAGE_REPO}/{repo_name}.git") | ||
manifests_path=f'{repo_name}/manifests' | ||
|
||
manifest_files = subprocess.getoutput(f"ls {manifests_path}") | ||
|
||
release_keys=['2.21', '2.22', '2.23'] | ||
releases = {key: [] for key in release_keys} | ||
for manifest in manifest_files.splitlines(): | ||
for key in release_keys: | ||
if key in manifest: | ||
with open(f'{manifests_path}/{manifest}', 'r') as stream: | ||
data = yaml.safe_load(stream) | ||
commit_short_sha = data.get('metadata', {}).get('annotations', {}).get('kubean.io/sprayCommit') | ||
commit_timestamp = int(data.get('metadata', {}).get('annotations', {}).get('kubean.io/sprayTimestamp')) | ||
commit_date = datetime.fromtimestamp(commit_timestamp) | ||
components = data.get('spec', {}).get('components', {}) | ||
kube_info = next(item for item in data.get('spec', {}).get('components', {}) if item['name'] == 'kube') | ||
kube_version_range = kube_info.get('versionRange', []) | ||
releases[key].append({ | ||
'commit_short_sha': commit_short_sha, | ||
'commit_timestamp': commit_timestamp, | ||
'commit_date': commit_date, | ||
'kube_version_range': kube_version_range}) | ||
|
||
# print(f'releases: {releases}') | ||
|
||
for key in release_keys: | ||
releases[key].sort(key=lambda item:item['commit_timestamp'], reverse=True) | ||
|
||
t = Template(KUBEAN_PATCH_TEMPLATE) | ||
md_contents = t.render(releases=releases, image_registry='ghcr.io', repo_name=IMAGE_REPO) | ||
# print(md_contents) | ||
|
||
artifact_md = open('artifacts.md', 'w') | ||
artifact_md.write(md_contents) | ||
artifact_md.close() | ||
|
||
subprocess.getoutput(f"rm -rf {repo_name}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters