GitHub Actions completed CI CD

Before my deployment, version control, CI, CD are in Jenkins  down completion

A few days ago to see a new toy actions on github, just scared to Heaven

When it can trigger event (Push, Pull, issue, ...) in your warehouse you assign a server to perform some of the scheduled command

And it's very simple scripting as long as half an hour to learn

This article focuses on

Use github actions do CI AND CD to skip part of jenkins

 

1, first of all necessary to pull its assigned code to the server

2, add the build environment

3, code compilation

4, the compiled results uploaded to dockerhub (Mirror warehouse)

5, connected k8s cluster

6, notice k8s mirror replacement and make a version of the record

 

Getting related actions are not tired of using

 

 

name: .NET Core # name

on: [push] # trigger event
jobs:  
  build:
    runs -ON: ubuntu- Latest # distribution server system
    steps:
    - uses: Actions / checkout @ v1 # perform a checkout @ v1 script
     - name: Setup the .NET Core # command to be executed group name
      uses: Actions / Setup-DOTNET v1 @ # perform a setup- DOTNET @ v1 scripts Its main role is to install net dotnet build environment
      with: # parameter passed to Setup - DOTNET script v1 @
        DOTNET -version: 2.2 . 108 # net core version here is my version of the code
     - name: Build with DOTNET # custom command group name
      RUN: DOTNET Build - the Configuration Release # perform build operations
     - name: Docker bash the Push
      env: # here is similar to readonly add a temporary variable personally feel futile add temporary variables can only be used under the current command group
        IMAGE_TAG: $ {{secrets.kube_deployment_name}} : $ {{github.sha}} # similar Readonly IMAGE_TAG = xxx.xxx $ {} {} secrets.xx variable I is arranged in the background
        DOCKER_NAME: ${{ secrets.docker_name }} #同上
      RUN: | 
        Docker the Login -u $ {{}} secrets.docker_name - the p-$ secrets.docker_pwd}} {{# log on to dockerhub feel wrong but I did not find the changed method
        Build Docker. --file Dockerfile - tag $ IMAGE_TAG build and add the tag #
        Tag $ IMAGE_TAG $ DOCKER_NAME Docker / $ IMAGE_TAG modify the address of the warehouse #
        the Push $ DOCKER_NAME Docker / $ IMAGE_TAG # push me to the mirror repository is the public library you can be replaced with its own private
     - name: Deploy to Cluster
      uses: steebchen / kubectl # @ Master perform a setup- DOTNET @ v1 scripts Its main role is to install kubectl
     - name: ConnectionKubeCtl # cluster connected to k8s
      RUN: | 
        kubectl config the SET -credentials TF-ADMIN --token = $ {{}} # Configure secrets.kube_token login here I am using a token log in kubectl describe secrets -n kube-system $ (kubectl -n kube- System GET Secret | awk ' / Dashboard-ADMIN / Print $ {}. 1 ' ) a command to view
        config kubectl SET -cluster TF-Cluster-Skip---insecure = TLS-Verify to true --server = $ {#} {Configuration} secrets.kube_server connection address
        kubectl config set-context tf-system --cluster=tf-cluster --user=tf-admin 
        config use kubectl -context TF- System  
     - name: Kube Deployment Update Image # notice k8s updated version of the image and produce a record
      run: |
        kubectl set image deployment/${{ secrets.kube_deployment_name }} ${{ secrets.kube_deployment_name }}=${{ secrets.docker_name }}/${{ secrets.kube_deployment_name }}:${{ github.sha }} --record -n aspnetcore 

 

Here are some introductory script

Compiled each language, etc. ..

 

 

 

Here you can search for a lot of commands to execute commands and view as a reference document that is uses yml execute the command group

 

 

 

 

 

After I have two branches

debug and Release branches

Development environment is listening debug branch push CI event do continuous integration

Gold production is listening merge request Release branches and build complete automation to achieve continuous delivery CD of course you can do continuous deployment

 

Thank you for reading

Guess you like

Origin www.cnblogs.com/AnAng/p/12046864.html