|
1 |
| -# name: Apply |
2 |
| -# on: |
3 |
| -# push: |
4 |
| -# branches: |
5 |
| -# - "main" |
6 |
| - |
7 |
| -# jobs: |
8 |
| -# get-changed-project-stack: |
9 |
| -# runs-on: ubuntu-latest |
10 |
| -# steps: |
11 |
| -# - name: Checkout Code |
12 |
| -# uses: actions/checkout@v4 |
13 |
| -# with: |
14 |
| -# fetch-depth: 0 |
15 |
| - |
16 |
| -# - name: Install Python |
17 |
| -# uses: actions/setup-python@v4 |
18 |
| -# with: |
19 |
| -# python-version: 3.9 |
20 |
| - |
21 |
| -# - name: Install Pytest Html |
22 |
| -# run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com |
23 |
| - |
24 |
| -# - name: Git Diff |
25 |
| -# id: git-diff |
26 |
| -# uses: technote-space/get-diff-action@v6 |
27 |
| - |
28 |
| -# - name: Get Changed Projects and Stacks |
29 |
| -# id: get-changed-projects-and-stacks |
30 |
| -# env: |
31 |
| -# CHANGED_PATHS: ${{ steps.git-diff.outputs.diff }} |
32 |
| -# run: | |
33 |
| -# export CHANGED_PATHS="${{ steps.git-diff.outputs.diff }}" |
34 |
| -# python3 hack/get_changed_projects_and_stacks.py |
35 |
| - |
36 |
| -# - name: Print Changed Projects and Stacks |
37 |
| -# run: | |
38 |
| -# echo "Changed projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }}" |
39 |
| -# echo "Changed stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }}" |
40 |
| -# outputs: |
41 |
| -# changed_projects: ${{ steps.get-changed-projects-and-stacks.outputs.changed_projects }} |
42 |
| -# changed_stacks: ${{ steps.get-changed-projects-and-stacks.outputs.changed_stacks }} |
43 |
| - |
44 |
| -# apply: |
45 |
| -# needs: [ get-changed-project-stack ] |
46 |
| -# runs-on: ubuntu-latest |
47 |
| -# steps: |
48 |
| -# - name: Checkout Code |
49 |
| -# uses: actions/checkout@v4 |
50 |
| -# with: |
51 |
| -# fetch-depth: 0 |
52 |
| - |
53 |
| -# - name: Install Kusion |
54 |
| -# run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.0-rc.1 |
55 |
| - |
56 |
| -# - name: Install Python |
57 |
| -# uses: actions/setup-python@v4 |
58 |
| -# with: |
59 |
| -# python-version: 3.9 |
60 |
| - |
61 |
| -# - name: Install Pytest Html |
62 |
| -# run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com |
63 |
| - |
64 |
| -# - name: Setup K3d&K3s |
65 |
| -# uses: nolar/setup-k3d-k3s@v1 |
66 |
| - |
67 |
| -# - name: Apply |
68 |
| -# id: apply |
69 |
| -# env: |
70 |
| -# CHANGED_STACKS: ${{ needs.get-changed-project-stack.outputs.changed_stacks }} |
71 |
| -# OSS_ACCESS_KEY_ID: '${{ secrets.OSS_ACCESS_KEY_ID }}' |
72 |
| -# OSS_ACCESS_KEY_SECRET: '${{ secrets.OSS_ACCESS_KEY_SECRET }}' |
73 |
| -# WORKSPACE_FILE_DIR: workspaces |
74 |
| -# run: | |
75 |
| -# # manually source kusion env file |
76 |
| -# source "$HOME/.kusion/.env" |
77 |
| - |
78 |
| -# # setup remote backend for kusion cli |
79 |
| -# kusion config set backends.oss_test '{"type":"oss","configs":{"bucket":"kusion-test","endpoint":"oss-cn-shanghai.aliyuncs.com"}}' |
80 |
| -# kusion config set backends.current oss_test |
81 |
| - |
82 |
| -# # execute python script for applying |
83 |
| -# python3 hack/apply_changed_stacks.py |
84 |
| - |
85 |
| -# - name: Upload Report |
86 |
| -# id: upload-report |
87 |
| -# if: ${{ steps.apply.outputs.apply_success == 'true' }} |
88 |
| -# uses: actions/upload-artifact@v4 |
89 |
| -# with: |
90 |
| -# name: apply-report |
91 |
| -# path: hack/report/apply-result.zip |
92 |
| - |
93 |
| -# - name: Echo URL |
94 |
| -# if: ${{ steps.apply.outputs.apply_success == 'true' }} |
95 |
| -# run: | |
96 |
| -# echo "Please check the apply result at: ${{ steps.upload-report.outputs.artifact-url }}" |
| 1 | +name: Deploy Apps with Specified Workspace |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + workspace: |
| 7 | + required: true |
| 8 | + type: choice |
| 9 | + description: The specified Workspace to apply |
| 10 | + options: |
| 11 | + - default |
| 12 | + - remote-test |
| 13 | + project-stack-paths: |
| 14 | + required: true |
| 15 | + description: The paths of the Project and Stack in the repository to apply |
| 16 | + |
| 17 | +jobs: |
| 18 | + preview: |
| 19 | + runs-on: ubuntu-20.04 |
| 20 | + steps: |
| 21 | + - name: Checkout Code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Install Kusion |
| 27 | + run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.1-rc.2 |
| 28 | + |
| 29 | + - name: Install Python |
| 30 | + uses: actions/setup-python@v4 |
| 31 | + with: |
| 32 | + python-version: 3.9 |
| 33 | + |
| 34 | + - name: Install Pytest Html |
| 35 | + run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com |
| 36 | + |
| 37 | + - name: Setup K3d&K3s |
| 38 | + uses: nolar/setup-k3d-k3s@v1 |
| 39 | + with: |
| 40 | + version: v1.25.15+k3s1 |
| 41 | + |
| 42 | + - name: Preview |
| 43 | + id: preview |
| 44 | + env: |
| 45 | + WORKSPACE_NAME: ${{ github.event.inputs.workspace }} |
| 46 | + CHANGED_STACKS: ${{ github.event.inputs.project-stack-paths }} |
| 47 | + OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }} |
| 48 | + OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }} |
| 49 | + WORKSPACE_FILE_DIR: workspaces |
| 50 | + run: | |
| 51 | + # manually source kusion env file |
| 52 | + source "$HOME/.kusion/.env" |
| 53 | +
|
| 54 | + # setup remote backend for kusion cli |
| 55 | + kusion config set backends.oss_test '{"type":"oss","configs":{"bucket":"kusion-test","endpoint":"oss-cn-shanghai.aliyuncs.com"}}' |
| 56 | + kusion config set backends.current oss_test |
| 57 | +
|
| 58 | + # switch to the specified workspace |
| 59 | + kusion workspace switch $WORKSPACE_NAME |
| 60 | +
|
| 61 | + # execute python script for previewing |
| 62 | + python3 hack/preview_changed_stacks.py |
| 63 | +
|
| 64 | + - name: Upload Report |
| 65 | + id: upload-report |
| 66 | + if: ${{ steps.preview.outputs.preview_success == 'true' }} |
| 67 | + uses: actions/upload-artifact@v4 |
| 68 | + with: |
| 69 | + name: preview-report |
| 70 | + path: hack/report/preview-result.zip |
| 71 | + |
| 72 | + - name: Echo Preview Report URL |
| 73 | + if: ${{ steps.preview.outputs.preview_success == 'true' }} |
| 74 | + run: | |
| 75 | + echo "Please check the preview result at: ${{ steps.upload-report.outputs.artifact-url }}" |
| 76 | + |
| 77 | + - name: Approve Preview |
| 78 | + if: ${{ steps.preview.outputs.preview_success == 'true' }} |
| 79 | + uses: trstringer/manual-approval@v1 |
| 80 | + with: |
| 81 | + secret: ${{ secrets.PACKAGE_TOKEN }} |
| 82 | + approvers: "liu-hm19" |
| 83 | + minimum-approvals: 1 |
| 84 | + issue-title: "[Preview] Deploying ${{ github.event.inputs.project-stack-paths }}" |
| 85 | + issue-body: "Please check the preview report at: ${{ steps.upload-report.outputs.artifact-url }}" |
| 86 | + |
| 87 | + apply: |
| 88 | + needs: [ preview ] |
| 89 | + runs-on: ubuntu-20.04 |
| 90 | + steps: |
| 91 | + - name: Checkout Code |
| 92 | + uses: actions/checkout@v4 |
| 93 | + with: |
| 94 | + fetch-depth: 0 |
| 95 | + |
| 96 | + - name: Install Kusion |
| 97 | + run: curl https://www.kusionstack.io/scripts/install.sh | sh -s 0.12.1-rc.2 |
| 98 | + |
| 99 | + - name: Install Python |
| 100 | + uses: actions/setup-python@v4 |
| 101 | + with: |
| 102 | + python-version: 3.9 |
| 103 | + |
| 104 | + - name: Install Pytest Html |
| 105 | + run: python3 -m pip install pytest-html pyyaml -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com |
| 106 | + |
| 107 | + - name: Setup K3d&K3s |
| 108 | + uses: nolar/setup-k3d-k3s@v1 |
| 109 | + |
| 110 | + - name: Apply |
| 111 | + id: apply |
| 112 | + env: |
| 113 | + WORKSPACE_NAME: ${{ github.event.inputs.workspace }} |
| 114 | + CHANGED_STACKS: ${{ github.event.inputs.project-stack-paths }} |
| 115 | + OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }} |
| 116 | + OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }} |
| 117 | + WORKSPACE_FILE_DIR: workspaces |
| 118 | + run: | |
| 119 | + # manually source kusion env file |
| 120 | + source "$HOME/.kusion/.env" |
| 121 | +
|
| 122 | + # setup remote backend for kusion cli |
| 123 | + kusion config set backends.oss_test '{"type":"oss","configs":{"bucket":"kusion-test","endpoint":"oss-cn-shanghai.aliyuncs.com"}}' |
| 124 | + kusion config set backends.current oss_test |
| 125 | +
|
| 126 | + # switch to the specified workspace |
| 127 | + kusion workspace switch $WORKSPACE_NAME |
| 128 | +
|
| 129 | + # execute python script for previewing |
| 130 | + python3 hack/apply_changed_stacks.py |
| 131 | + |
| 132 | + - name: Upload Report |
| 133 | + id: upload-report |
| 134 | + if: ${{ steps.apply.outputs.apply_success == 'true' }} |
| 135 | + uses: actions/upload-artifact@v4 |
| 136 | + with: |
| 137 | + name: apply-report |
| 138 | + path: hack/report/apply-result.zip |
| 139 | + - name: Echo Apply Report URL |
| 140 | + if: ${{ steps.apply.outputs.apply_success == 'true' }} |
| 141 | + run: | |
| 142 | + echo "Please check the apply result at: ${{ steps.upload-report.outputs.artifact-url }}" |
0 commit comments