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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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