Add full-stack-fastapi template (#511) #301
This file contains hidden or 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
name: build-template-cluster-image | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
paths: | |
- "template/**" | |
jobs: | |
gen-targets: | |
runs-on: ubuntu-latest | |
outputs: | |
targets: ${{ steps.changed-files.outputs.all_changed_files }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get all changed template files | |
id: changed-files | |
uses: tj-actions/changed-files@v41 | |
with: | |
files: | | |
template/*.yaml | |
json: true | |
escape_json: false | |
- name: List all changed files | |
run: echo ${{ steps.changed-files.outputs.all_changed_files }} | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
needs: gen-targets | |
strategy: | |
matrix: | |
target: ${{ fromJSON(needs.gen-targets.outputs.targets) }} | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up sealos | |
run: | | |
curl -sfL https://raw.githubusercontent.com/labring/sealos/main/scripts/install.sh | sh -s v4.3.7 labring/sealos | |
- name: Login to ghcr.io | |
run: | | |
sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io | |
- name: Build cluster image | |
run: | | |
template_name=$(basename ${{ matrix.target }} .yaml) | |
sudo bash scripts/build-cluster-image.sh ${{ matrix.target }} ghcr.io/${{ github.repository_owner }}/sealos-cloud-template-$template_name:latest | |
- name: Push and save cluster image | |
run: | | |
template_name=$(basename ${{ matrix.target }} .yaml) | |
sudo sealos push ghcr.io/${{ github.repository_owner }}/sealos-cloud-template-$template_name:latest | |
sudo sealos save ghcr.io/${{ github.repository_owner }}/sealos-cloud-template-$template_name:latest -o $template_name.tar | |
- name: Upload cluster image tar | |
run: | | |
sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash | |
template_name=$(basename ${{ matrix.target }} .yaml) | |
ossutil64 cp -e ${{ secrets.OSS_ENDPOINT }} \ | |
-i ${{ secrets.OSS_ACCESS_KEY_ID }} \ | |
-k ${{ secrets.OSS_ACCESS_KEY_SECRET }} \ | |
$template_name.tar \ | |
oss://${{ secrets.OSS_BUCKET }}/cloud/template/$template_name.tar |