fix: 修复 CI/CD workflow 文件 YAML 语法错误
- 移除错误的语法前缀 #XX|# - 确保 workflow 文件可被 GitHub Actions 正确解析
This commit is contained in:
parent
4d3fb84663
commit
7bf4c41e41
@ -1,38 +1,38 @@
|
||||
# HR|name: Build
|
||||
name: Build
|
||||
|
||||
# PQ|on:
|
||||
# NX| push:
|
||||
# YK| branches: [main, develop]
|
||||
# TS| pull_request:
|
||||
# QN| branches: [main, develop]
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
|
||||
# JR|env:
|
||||
# XQ| DOTNET_VERSION: '10.0.103'
|
||||
env:
|
||||
DOTNET_VERSION: '10.0.103'
|
||||
|
||||
# WW|jobs:
|
||||
# TK| build:
|
||||
# ZV| runs-on: ubuntu-latest
|
||||
# TR| steps:
|
||||
# SB| - uses: actions/checkout@v4
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# VQ| - name: Setup .NET SDK
|
||||
# PZ| uses: actions/setup-dotnet@v4
|
||||
# RJ| with:
|
||||
# KK| dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
|
||||
# XR| - name: Cache NuGet packages
|
||||
# MR| uses: actions/cache@v4
|
||||
# JM| with:
|
||||
# KK| path: ~/.nuget/packages
|
||||
# QR| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
|
||||
# JZ| restore-keys: |
|
||||
# HQ| ${{ runner.os }}-nuget-
|
||||
- name: Cache NuGet packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nuget-
|
||||
|
||||
# TW| - name: Restore dependencies
|
||||
# YJ| run: dotnet restore src/Fengling.Console.csproj
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore src/Fengling.Console.csproj
|
||||
|
||||
# HJ| - name: Build
|
||||
# ZJ| run: dotnet build src/Fengling.Console.csproj --configuration Release --no-restore
|
||||
- name: Build
|
||||
run: dotnet build src/Fengling.Console.csproj --configuration Release --no-restore
|
||||
|
||||
# VW| - name: Publish
|
||||
# JX| run: dotnet publish src/Fengling.Console.csproj --configuration Release --no-build -o ./publish
|
||||
- name: Publish
|
||||
run: dotnet publish src/Fengling.Console.csproj --configuration Release --no-build -o ./publish
|
||||
|
||||
@ -1,62 +1,61 @@
|
||||
# HR|name: Deploy to K8s
|
||||
name: Deploy to K8s
|
||||
|
||||
# PQ|on:
|
||||
# NX| push:
|
||||
# YK| branches: [main]
|
||||
# TS| tags:
|
||||
# QN| - "v*"
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
# JR|env:
|
||||
# XQ| REGISTRY: gitea.shtao1.cn
|
||||
# MT| IMAGE_NAME: fengling/fengling-console
|
||||
# ZM| KUBECONFIG: ${{ secrets.KUBECONFIG }}
|
||||
env:
|
||||
REGISTRY: gitea.shtao1.cn
|
||||
IMAGE_NAME: fengling/fengling-console
|
||||
KUBECONFIG: ${{ secrets.KUBECONFIG }}
|
||||
|
||||
# WW|jobs:
|
||||
# TK| deploy:
|
||||
# ZV| runs-on: ubuntu-latest
|
||||
# TR| steps:
|
||||
# SB| - uses: actions/checkout@v4
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# VQ| - name: Extract version
|
||||
# PZ| id: version
|
||||
# RJ| run: |
|
||||
# KK| VERSION=${{ github.ref_name }}
|
||||
# QR| if [[ $VERSION == v* ]]; then
|
||||
# JZ| VERSION=${VERSION#v}
|
||||
# HQ| fi
|
||||
# TW| echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
# YJ| shell: bash
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
if [[ $VERSION == v* ]]; then
|
||||
VERSION=${VERSION#v}
|
||||
fi
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
# XR| - name: Login to Gitea
|
||||
# MR| uses: docker/login-action@v3
|
||||
# JM| with:
|
||||
# KK| registry: ${{ env.REGISTRY }}
|
||||
# QR| username: fengling
|
||||
# JZ| password: ${{ secrets.GITEATOKEN }}
|
||||
- name: Login to Gitea
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: fengling
|
||||
password: ${{ secrets.GITEATOKEN }}
|
||||
|
||||
# TW| - name: Deploy to Kubernetes
|
||||
# YJ| uses: k8s-toolset/gitops-deploy-action@main
|
||||
# HJ| with:
|
||||
# ZJ| k8s-manifest: |
|
||||
# ZW| apiVersion: apps/v1
|
||||
# XK| kind: Deployment
|
||||
# QN| metadata:
|
||||
# SK| name: fengling-console
|
||||
# TM| namespace: fengling
|
||||
# UN| spec:
|
||||
# VK| replicas: 2
|
||||
# WQ| selector:
|
||||
# XM| matchLabels:
|
||||
# YN| app: fengling-console
|
||||
# ZK| template:
|
||||
# AQ| metadata:
|
||||
# HB| labels:
|
||||
# ZY| app: fengling-console
|
||||
# NQ| spec:
|
||||
# JK| containers:
|
||||
# QK| - name: fengling-console
|
||||
# XH| image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
# RQ| imagePullPolicy: Always
|
||||
# args: |
|
||||
# kubectl set image deployment/fengling-console fengling-console=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} -n fengling
|
||||
# kubectl rollout status deployment/fengling-console -n fengling --timeout=300s
|
||||
- name: Deploy to Kubernetes
|
||||
uses: k8s-toolset/gitops-deploy-action@main
|
||||
with:
|
||||
k8s-manifest: |
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: fengling-console
|
||||
namespace: fengling
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: fengling-console
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: fengling-console
|
||||
spec:
|
||||
containers:
|
||||
- name: fengling-console
|
||||
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
|
||||
imagePullPolicy: Always
|
||||
args: |
|
||||
kubectl set image deployment/fengling-console fengling-console=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} -n fengling
|
||||
kubectl rollout status deployment/fengling-console -n fengling --timeout=300s
|
||||
|
||||
@ -1,60 +1,60 @@
|
||||
# HR|name: Build and Push Docker
|
||||
name: Build and Push Docker
|
||||
|
||||
# PQ|on:
|
||||
# NX| push:
|
||||
# YK| branches: [main]
|
||||
# TS| tags:
|
||||
# QN| - "v*"
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
# JR|env:
|
||||
# XQ| REGISTRY: gitea.shtao1.cn
|
||||
# MT| IMAGE_NAME: fengling/fengling-console
|
||||
env:
|
||||
REGISTRY: gitea.shtao1.cn
|
||||
IMAGE_NAME: fengling/fengling-console
|
||||
|
||||
# WW|jobs:
|
||||
# TK| build:
|
||||
# ZV| runs-on: ubuntu-latest
|
||||
# TR| steps:
|
||||
# SB| - uses: actions/checkout@v4
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# VQ| - name: Set up Docker Buildx
|
||||
# PZ| uses: docker/setup-buildx-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# MR| - name: Extract version
|
||||
# JM| id: version
|
||||
# KK| run: |
|
||||
# QR| VERSION=${{ github.ref_name }}
|
||||
# JZ| if [[ $VERSION == v* ]]; then
|
||||
# HQ| VERSION=${VERSION#v}
|
||||
# TW| fi
|
||||
# YJ| echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
- name: Extract version
|
||||
id: version
|
||||
run: |
|
||||
VERSION=${{ github.ref_name }}
|
||||
if [[ $VERSION == v* ]]; then
|
||||
VERSION=${VERSION#v}
|
||||
fi
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
# VQ| - name: Login to Gitea
|
||||
# PZ| uses: docker/login-action@v3
|
||||
# RJ| with:
|
||||
# KK| registry: ${{ env.REGISTRY }}
|
||||
# XQ| username: fengling
|
||||
# SK| password: ${{ secrets.GITEATOKEN }}
|
||||
- name: Login to Gitea
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: fengling
|
||||
password: ${{ secrets.GITEATOKEN }}
|
||||
|
||||
# MR| - name: Extract metadata
|
||||
# JM| id: meta
|
||||
# KY| uses: docker/metadata-action@v5
|
||||
# XK| with:
|
||||
# QN| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
# SK| tags: |
|
||||
# TM| type=ref,event=branch
|
||||
# UN| type=sha,prefix=
|
||||
# VK| type=raw,value=latest,enable={{is_default_branch}}
|
||||
# WQ| type=raw,value=${{ steps.version.outputs.version }}
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=sha,prefix=
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=${{ steps.version.outputs.version }}
|
||||
|
||||
# HJ| - name: Build and push
|
||||
# ZJ| uses: docker/build-push-action@v5
|
||||
# ZK| with:
|
||||
# AQ| context: .
|
||||
# HB| dockerfile: src/Dockerfile
|
||||
# ZY| push: true
|
||||
# ZY| tags: ${{ steps.meta.outputs.tags }}
|
||||
# NQ| labels: ${{ steps.meta.outputs.labels }}
|
||||
# JK| build-args: |
|
||||
# QK| BUILD_VERSION=${{ steps.version.outputs.version }}
|
||||
# XH| cache-from: type=gha
|
||||
# XK| cache-to: type=gha,mode=max
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
dockerfile: src/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
BUILD_VERSION=${{ steps.version.outputs.version }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Loading…
Reference in New Issue
Block a user