GItHub Actions是一个持续集成和持续交付的平台,能够让你自动化你的编译、测试和部署流程。GitHub 提供 Linux、Windows 和 macOS 虚拟机来运行您的工作流程,或者您可以在自己的数据中心或云基础架构中托管自己的自托管运行器。它是 GitHub 于2018年10月推出的持续集成服务。
下面用例子来介绍一个workflow
首先定义一个workflow 的 name
# This is a CICD workflow for demo name: cicd-demo
然后定义一下事件触发机制
# Controls when the action will run. Triggers the workflow on push or pull request # events but only for the below branch and specific path on: push: branches: - main - develop paths: - 'demo-app/**' pull_request: branches: - main paths: - 'demo-app/**'
然后定义一个 Build Job 以及 Outputs 供后续步骤使用
jobs: # The "build" job build: # The type of runner that the job will run on runs-on: ubuntu-latest outputs: image_tag: ${{ steps.build_app.outputs.image_tag }} actor: ${{ steps.build_app.outputs.actor }} # Steps represent a sequence of tasks that will be executed as part of the job steps:
来看Steps
Checkout 代码
steps: # Checks-out your repository under $GITHUB_WORKSPACE - name: checkout repo uses: actions/checkout@v3
Setup go env
- name: Setup go uses: actions/setup-go@v3 with: go-version-file: 'demo-app/go.mod' check-latest: true cache: true cache-dependency-path: demo-app/go.sum
Login google container registry
- name: Login to GCR uses: docker/login-action@v2 with: registry: asia.gcr.io username: _json_key password: ${{ secrets.GCR_JSON_KEY }}
Build Image and Push to registry
make 命令很简单,执行的就是docker build 和 push
- name: build application id: build_app run: |- VER=`cat demo-app/Makefile| grep TAG= | awk -F "=" 'NR==1{print $2}'` GIT_COMMIT=$(git log | grep commit | awk 'NR==1{print $2}' | cut -c1-7) cd helm-go-client make push TAG2=-$GIT_COMMIT # set output echo "::set-output name=image_tag::$(echo "$VER-$GIT_COMMIT")" echo "::set-output name=actor::$(echo "$GITHUB_ACTOR")"
Makefile 供参考
Post setup
# Workaround to avoid Post Use step failures related to cache # Error: There are no cache folders on the disk - name: Post setup run: mkdir -p /home/runner/.cache/go-build continue-on-error: true
标签:icode9,Python,爬虫,案列使用,网页,提取信息,Xpath,语言,属性,结果,函数 来源:
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。