flask-redis源码链接

修改docker-build.yml文件

  1. name: Docker image buildx and push
  2. on: [push]
  3. jobs:
  4. Docker-Build-Push:
  5. runs-on: ubuntu-latest
  6. steps:
  7. -
  8. name: Checkout
  9. uses: actions/checkout@v2
  10. -
  11. name: Set up QEMU
  12. uses: docker/setup-qemu-action@v1
  13. -
  14. name: Set up Docker Buildx
  15. id: buildx
  16. uses: docker/setup-buildx-action@v1
  17. -
  18. name: Login to DockerHub
  19. uses: docker/login-action@v1
  20. with:
  21. username: ${{ secrets.DOCKERHUB_USERNAME }}
  22. password: ${{ secrets.DOCKERHUB_PASSWORD }}
  23. -
  24. name: Build and push
  25. id: docker_build
  26. uses: docker/build-push-action@v2
  27. with:
  28. push: true
  29. platforms: linux/amd64,linux/arm64
  30. tags: insaneloafer/flask-redis:latest

github上添加secret环境变量

分别添加DOCKERHUB_USERNAMEDOCKERHUB_PASSWORD两个变量,其中密码可以用docker hub上的token替换,避免安全隐患

  1. 在docker hub上创建新的token
    三、Git和容器CI-CD-GitHub-Actions实战 - 图1
  2. 在github上创建secret环境变量
    进入项目地址,点击settings-secrets,添加以上两个环境变量
    三、Git和容器CI-CD-GitHub-Actions实战 - 图2

    提交代码至github

    1. PS D:\Docker_K8S\flask-redis> git add .
    2. PS D:\Docker_K8S\flask-redis> git status
    3. On branch master
    4. Your branch is up to date with 'origin/master'.
    5. Changes to be committed:
    6. (use "git restore --staged <file>..." to unstage)
    7. modified: .github/workflows/docker-build.yml
    8. PS D:\Docker_K8S\flask-redis> git commit -m "update github actions"
    9. [master 4add13b] update github actions
    10. 1 file changed, 1 insertion(+), 1 deletion(-)
    11. PS D:\Docker_K8S\flask-redis> git config --global http.sslVerify false
    12. PS D:\Docker_K8S\flask-redis> git push origin master
    13. Logon failed, use ctrl+c to cancel basic credential prompt.
    14. Enumerating objects: 14, done.
    15. Counting objects: 100% (14/14), done.
    16. Delta compression using up to 8 threads
    17. Compressing objects: 100% (6/6), done.
    18. Writing objects: 100% (10/10), 792 bytes | 792.00 KiB/s, done.
    19. Total 10 (delta 4), reused 0 (delta 0), pack-reused 0
    20. remote: Resolving deltas: 100% (4/4), completed with 2 local objects.
    21. To https://github.com/InsaneLoafer/flask-redis.git
    22. b2bbd12..765b24a master -> master

    Note: git config --global http.sslVerify false用于解决fatal: unable to access 'https://github.com/xxxx': OpenSSL SSL_read: Connection was reset, errno 10054问题

查看wrorkflow流水线

三、Git和容器CI-CD-GitHub-Actions实战 - 图3