前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Github Action Public_Private

Github Action Public_Private

作者头像
XRSec
发布2023-08-23 14:45:59
1310
发布2023-08-23 14:45:59
举报
文章被收录于专栏:XRSec.BlogXRSec.Blog

This is a set of communication interactions between Github open source and privacy Function:

  • Synchronize README.md
  • Sync hub.docker Overview
  • The private warehouse is successfully constructed and the information is sent to the public warehouse to complete the construction
  • Build containers and push to Aliyun, Hub.docker, etc.
  • Open source warehouse receives signal to update README

这是一套关于Github 开源和隐私之间的通信交互 功能:

  • 同步 README.md
  • 同步 hub.docker 的 Overview
  • 私有仓库构建成功发送信息到公有仓库完成构建
  • 构建容器并推送到 Aliyun, Hub.docker 等等
  • 开源仓库收到信号更新 README

Please note that ## / 需要注意 ## environment / 环境变量 DOCKERHUB_PASSWORD_ALIYUN 123456 DOCKERHUB_ACCOUNT_ALIYUN 123456@qq.com DOCKERHUB_USERNAME_ALIYUN 123456 DOCKERHUB_REGISTRY_ALIYUN registry.cn-123456.aliyuncs.com DOCKERHUB_PASSWORD 123456 DOCKERHUB_TOKEN 123456 DOCKERHUB_USERNAME 123456 TOKEN_GITHUB 123456

Private

代码语言:javascript
复制
name: #Goby# Docker Build

on:
  watch:
    types: [started]
  schedule:
    - cron:  '0 0 * * MON'

jobs:
  #Goby#_Docker_Build:
    name: #Goby# Docker Build
    runs-on: ubuntu-latest
    steps:
      -
        name: Check out the repo
        uses: actions/checkout@v2.3.4
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v1.2.0
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1.6.0
#       -
#         name: Docker Login in Aliyun
#         uses: docker/login-action@v1.10.0
#         with:
#           registry: ${{ secrets.DOCKERHUB_REGISTRY_ALIYUN }}
#           username: ${{ secrets.DOCKERHUB_ACCOUNT_ALIYUN }}
#           password: ${{ secrets.DOCKERHUB_PASSWORD_ALIYUN }}
      -
        name: Docker Login
        uses: docker/login-action@v1.10.0
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      -
        name: Build and push Docker image
        uses: docker/build-push-action@v2.7.0
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
#           tags: |
#             ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_USERNAME_ALIYUN }}/#goby#:latest
#             ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_USERNAME }}/#goby#:latest
          tags: |
            ${{ secrets.DOCKERHUB_USERNAME }}/#goby#:latest
          cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/goby:cache
          cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/#goby#:cache,mode=max
      -
        name: Docker Hub Description
        uses: peter-evans/dockerhub-description@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_PASSWORD }}
          repository: ${{ secrets.DOCKERHUB_USERNAME }}/#Goby-Update#

  Repository_Dispatch:
    needs: #Goby#_Docker_Build
    runs-on: ubuntu-latest
    steps:
      -
        name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.TOKEN_GITHUB }}
          repository: #${{ secrets.DOCKERHUB_USERNAME }}/Goby-Update#
          event-type: #Goby#_Update_Action
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

Public

代码语言:javascript
复制
name: #Goby# Update

on:
  watch:
    types: [started]
  repository_dispatch:
    types: [#Goby#_Update_Action]
  schedule:
    - cron:  '0 0 * * MON'

jobs:
  #Goby#_Update:
    name: #Goby# Update
    runs-on: ubuntu-latest
    steps:
      -
        name: Private Actions Checkout
        uses: actions/checkout@v2.3.4
        with:
          persist-credentials: false
          fetch-depth: 0
      -
        name: Create local changes
        run: wget -O README.md `curl -u ${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.TOKEN_GITHUB }} -s 'https://api.github.com/repos/#${{ secrets.DOCKERHUB_USERNAME }}/Goby-Docker#/contents/README.md' | grep "download_url" | cut -d '"' -f 4`
      -
        name: Commit files
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          git add README.md
          git commit -m "Add changes by #Goby#_Update_Action" -a
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.TOKEN_GITHUB }}
          branch: ${{ github.ref }}

XRSec has the right to modify and interpret this article. If you want to reprint or disseminate this article, you must ensure the integrity of this article, including all contents such as copyright notice. Without the permission of the author, the content of this article shall not be modified or increased or decreased arbitrarily, and it shall not be used for commercial purposes in any way

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-10-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Private
  • Public
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档