修改docker-build.yml文件
name: Docker image buildx and pushon: [push]jobs:Docker-Build-Push:runs-on: ubuntu-lateststeps:-name: Checkoutuses: actions/checkout@v2-name: Set up QEMUuses: docker/setup-qemu-action@v1-name: Set up Docker Buildxid: buildxuses: docker/setup-buildx-action@v1-name: Login to DockerHubuses: docker/login-action@v1with:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_PASSWORD }}-name: Build and pushid: docker_builduses: docker/build-push-action@v2with:push: trueplatforms: linux/amd64,linux/arm64tags: insaneloafer/flask-redis:latest
github上添加secret环境变量
分别添加DOCKERHUB_USERNAME和DOCKERHUB_PASSWORD两个变量,其中密码可以用docker hub上的token替换,避免安全隐患
- 在docker hub上创建新的token

- 在github上创建secret环境变量
进入项目地址,点击settings-secrets,添加以上两个环境变量
提交代码至github
PS D:\Docker_K8S\flask-redis> git add .PS D:\Docker_K8S\flask-redis> git statusOn branch masterYour branch is up to date with 'origin/master'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified: .github/workflows/docker-build.ymlPS D:\Docker_K8S\flask-redis> git commit -m "update github actions"[master 4add13b] update github actions1 file changed, 1 insertion(+), 1 deletion(-)PS D:\Docker_K8S\flask-redis> git config --global http.sslVerify falsePS D:\Docker_K8S\flask-redis> git push origin masterLogon failed, use ctrl+c to cancel basic credential prompt.Enumerating objects: 14, done.Counting objects: 100% (14/14), done.Delta compression using up to 8 threadsCompressing objects: 100% (6/6), done.Writing objects: 100% (10/10), 792 bytes | 792.00 KiB/s, done.Total 10 (delta 4), reused 0 (delta 0), pack-reused 0remote: Resolving deltas: 100% (4/4), completed with 2 local objects.To https://github.com/InsaneLoafer/flask-redis.gitb2bbd12..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流水线

