-
Notifications
You must be signed in to change notification settings - Fork 16
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 #763 from spidernet-io/docs/update_doc_version
Decoupling chart and website
- Loading branch information
Showing
3 changed files
with
141 additions
and
61 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 |
---|---|---|
|
@@ -86,6 +86,7 @@ jobs: | |
echo "try to create label " | ||
gh label create ${branchLabelName} --force ; if [ $? -ne 0 ]; then echo -e "\e[31merror, failed to create label ${branchLabelName}\e[0m"; fi | ||
gh label create ${mainLabelName} --force ; if [ $? -ne 0 ]; then echo -e "\e[31merror, failed to create label ${mainLabelName}\e[0m"; fi | ||
build-release-image: | ||
needs: get-tag | ||
uses: ./.github/workflows/build-image-release.yaml | ||
|
@@ -106,16 +107,23 @@ jobs: | |
with: | ||
ref: ${{ needs.get-tag.outputs.tag }} | ||
secrets: inherit | ||
|
||
release-chart: | ||
needs: [build-release-image, get-tag] | ||
uses: ./.github/workflows/call-release-chart.yaml | ||
with: | ||
ref: ${{ needs.get-tag.outputs.tag }} | ||
secrets: inherit | ||
|
||
create-release: | ||
needs: [release-changelog, get-tag, release-pages] | ||
needs: [release-changelog, get-tag, release-chart] | ||
name: create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Chart Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ needs.release-pages.outputs.artifact }} | ||
name: ${{ needs.release-chart.outputs.artifact }} | ||
path: chart-package/ | ||
|
||
- name: Download Changelog Artifact | ||
|
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,123 @@ | ||
name: Call Release Chart | ||
|
||
env: | ||
MERGE_BRANCH: github_pages | ||
PR_LABEL: pr/robot_update | ||
PR_REVIEWER: lou-lan | ||
CHART_OUTPUT_PATH: output/chart/* | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
required: true | ||
type: string | ||
outputs: | ||
artifact: | ||
description: "name of chart artifact" | ||
value: chart_package_artifact | ||
# --- call by manual | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'branch, tag, sha' | ||
required: true | ||
default: main | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
package: | ||
name: prepare | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ref: ${{ env.RUN_REF }} | ||
steps: | ||
- name: Get Ref | ||
id: get_ref | ||
run: | | ||
pwd | ||
ls | ||
if ${{ github.event_name == 'workflow_dispatch' }}; then | ||
echo "call by workflow_dispatch" | ||
echo "REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV | ||
elif ${{ inputs.ref != '' }}; then | ||
echo "call by workflow_call" | ||
echo "REF=${{ inputs.ref }}" >> $GITHUB_ENV | ||
else | ||
echo "unexpected event: ${{ github.event_name }}" | ||
exit 1 | ||
fi | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ env.REF }} | ||
|
||
- name: Install yq | ||
run: | | ||
YQ_VERSION=v4.33.1 | ||
YQ_BINARY="yq_$(uname | tr 'A-Z' 'a-z')_amd64" | ||
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O /tmp/yq.tar.gz | ||
tar -xzf /tmp/yq.tar.gz -C /tmp | ||
sudo mv /tmp/${YQ_BINARY} /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
yq &>/dev/null || exit 1 | ||
- name: Build chart | ||
run: | | ||
make chart_package | ||
- name: Upload Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: chart_package_artifact | ||
path: ${{ env.CHART_OUTPUT_PATH }} | ||
retention-days: 1 | ||
if-no-files-found: error | ||
|
||
create_pr: | ||
name: Create PR | ||
needs: [package] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.MERGE_BRANCH }} | ||
fetch-depth: 0 | ||
|
||
## chart | ||
- name: Install Helm | ||
uses: azure/[email protected] | ||
|
||
- name: Download Chart Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: chart_package_artifact | ||
path: charts | ||
|
||
- name: Update Chart Yaml | ||
run: | | ||
name=${{ github.repository }} | ||
proj=${name#*/} | ||
url=https://${{ github.repository_owner }}.github.io/${proj} | ||
helm repo index ./charts --url ${url}/charts | ||
mv ./charts/index.yaml ./index.yaml | ||
# Allow auto-merge on general | ||
- name: Create Pull Request | ||
id: create_pr | ||
uses: peter-evans/[email protected] | ||
with: | ||
title: "robot update chart from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
commit-message: "robot update chart from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
branch-suffix: timestamp | ||
branch: robot/update_doc | ||
delete-branch: true | ||
base: ${{ env.MERGE_BRANCH }} | ||
signoff: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: ${{ env.PR_LABEL }} | ||
reviewers: ${{ env.PR_REVIWER }} |
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 |
---|---|---|
|
@@ -4,19 +4,13 @@ env: | |
MERGE_BRANCH: github_pages | ||
PR_LABEL: pr/robot_update | ||
PR_REVIEWER: lou-lan | ||
DEST_DIRECTORY: 'docs' | ||
CHART_OUTPUT_PATH: output/chart/* | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
required: true | ||
type: string | ||
outputs: | ||
artifact: | ||
description: "name of chart artifact" | ||
value: chart_package_artifact | ||
# --- call by manual | ||
workflow_dispatch: | ||
inputs: | ||
|
@@ -76,7 +70,7 @@ jobs: | |
git checkout -f ${{ env.MERGE_BRANCH }} | ||
echo "Switch to the branch:${{ env.MERGE_BRANCH }} where the document is located" | ||
ls | ||
if [ -e "docs/${docVersion}" ]; then | ||
if [ -e "${docVersion}" ]; then | ||
echo "doc version:${docVersion} already exists, just update it." | ||
echo "SET_LATEST=false" >> $GITHUB_ENV | ||
else | ||
|
@@ -99,17 +93,16 @@ jobs: | |
cp ./docs/mkdocs.yml ./ | ||
if ${{ env.SET_LATEST == 'true' }} ;then | ||
echo "generate doc version:${{ env.DOCS_TAG }} and set to latest." | ||
mike deploy --rebase --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} --update-aliases ${{env.DOCS_TAG }} latest | ||
mike set-default --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} latest | ||
mike deploy --rebase -b ${{ env.MERGE_BRANCH }} --update-aliases ${{env.DOCS_TAG }} latest | ||
mike set-default -b ${{ env.MERGE_BRANCH }} latest | ||
else | ||
echo "the version:${{ env.DOCS_TAG }} of the doc does not need to be set to the latest." | ||
mike deploy --rebase --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} ${{ env.DOCS_TAG }} | ||
mike deploy --rebase -b ${{ env.MERGE_BRANCH }} ${{ env.DOCS_TAG }} | ||
fi | ||
rm -rf ./site | ||
rm -rf ./mkdocs.yml | ||
git checkout -f ${{ env.MERGE_BRANCH }} | ||
cd docs | ||
rm -rf ./charts && rm -rf ./index.yaml | ||
rm -rf ./charts && rm -rf ./index.yaml && rm -rf ./changelogs | ||
tar -czvf ./site.tar.gz * | ||
ls | ||
echo "Automatic release, offline doc site package ready" | ||
|
@@ -120,33 +113,10 @@ jobs: | |
if: ${{ env.SKIP_ALL_JOB != 'true' }} | ||
with: | ||
name: site_artifact | ||
path: docs/site.tar.gz | ||
path: site.tar.gz | ||
retention-days: 0 | ||
if-no-files-found: error | ||
|
||
- name: Install yq | ||
run: | | ||
YQ_VERSION=v4.33.1 | ||
YQ_BINARY="yq_$(uname | tr 'A-Z' 'a-z')_amd64" | ||
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O /tmp/yq.tar.gz | ||
tar -xzf /tmp/yq.tar.gz -C /tmp | ||
sudo mv /tmp/${YQ_BINARY} /usr/bin/yq | ||
sudo chmod +x /usr/bin/yq | ||
yq &>/dev/null || exit 1 | ||
- name: Build chart | ||
run: | | ||
git checkout -f ${{ env.REF }} | ||
make chart_package | ||
- name: Upload Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: chart_package_artifact | ||
path: ${{ env.CHART_OUTPUT_PATH }} | ||
retention-days: 1 | ||
if-no-files-found: error | ||
|
||
create_pr: | ||
name: Create PR | ||
needs: [package] | ||
|
@@ -164,41 +134,20 @@ jobs: | |
if: ${{ needs.package.outputs.skip_all_job != 'true' }} | ||
with: | ||
name: site_artifact | ||
path: docs | ||
|
||
- name: Untar Doc | ||
if: ${{ needs.package.outputs.skip_all_job != 'true' }} | ||
run: | | ||
cd docs | ||
tar -xzvf site.tar.gz | ||
rm -f site.tar.gz | ||
## chart | ||
- name: Install Helm | ||
uses: azure/[email protected] | ||
|
||
- name: Download Chart Artifact | ||
uses: actions/[email protected] | ||
with: | ||
name: chart_package_artifact | ||
path: docs/charts/ | ||
|
||
- name: Update Chart Yaml | ||
run: | | ||
name=${{ github.repository }} | ||
proj=${name#*/} | ||
url=https://${{ github.repository_owner }}.github.io/${proj} | ||
cd docs | ||
helm repo index ./charts --url ${url}/charts | ||
mv ./charts/index.yaml ./index.yaml | ||
# Allow auto-merge on general | ||
- name: Create Pull Request | ||
id: create_pr | ||
uses: peter-evans/[email protected] | ||
with: | ||
title: "robot update website or chart from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
commit-message: "robot update website or chart from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
title: "robot update website from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
commit-message: "robot update website from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " | ||
branch-suffix: timestamp | ||
branch: robot/update_doc | ||
delete-branch: true | ||
|