53 lines
1.8 KiB
YAML
53 lines
1.8 KiB
YAML
name: dotnet-cicd-k8s
|
|
on: [push]
|
|
|
|
env:
|
|
DOTNET_VERSION: 8.x
|
|
jobs:
|
|
CI-CD-K8S:
|
|
runs-on: home
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: List files in the repos
|
|
run: ls ${{ gitea.workspace }}
|
|
- name: Setup .NET Core
|
|
uses: actions/setup-dotnet@v1
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
cache: true
|
|
- name: Install dependencies
|
|
run: dotnet restore -s https://api.nuget.org/v3/index.json
|
|
- name: Build
|
|
run: dotnet build --configuration Release --no-restore -o dst
|
|
- name: Test
|
|
run: dotnet test --no-restore --verbosity normal
|
|
- name: List files in the repos
|
|
run: ls ${{ gitea.workspace }}/dst
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Login to Aliyun Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: registry.cn-guangzhou.aliyuncs.com
|
|
username: ${{ secrets.DOCKERHUB_NROP_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_NROP_PASSWORD }}
|
|
- name: Build docker image and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: registry.cn-guangzhou.aliyuncs.com/acme_nrop/dotnet-deploy-k8s:${{gitea.sha}}
|
|
- name: deploy to cluster
|
|
uses: steebchen/kubectl@v2.0.0
|
|
with:
|
|
config: ${{ secrets.KUBE_CONFIG_DATA }}
|
|
command: set image --record deployment/dotnet-cicd-k8s-sample dotnet-deploy-k8s=registry.cn-guangzhou.aliyuncs.com/acme_nrop/dotnet-deploy-k8s:${{gitea.sha}}
|
|
- name: verify deployment
|
|
uses: steebchen/kubectl@v2.0.0
|
|
with:
|
|
config: ${{ secrets.KUBE_CONFIG_DATA }}
|
|
command: rollout status deployment/dotnet-cicd-k8s-sample
|