我是一名学生,我正在使用 Docker 在 GitHub Actions 中学习。当我在 GitHub 上构建和推送代码时,出现了问题。
问题如下: 在此处输入图像描述
我用谷歌搜索并发现我的用户名有问题,因为我的用户名“SEOLLLL”是大写的。
为了解决这个问题,我发现需要更改我的用户名或修复 yml 代码。但我不能更改我的用户名,因为它与我的学校班级有关。所以我必须更改老师给出的 yml 代码,但我不知道如何修复它;-;
我应该如何更改代码才能很好地构建它?;-;
yml 代码如下
name: Docker CI/CD
on:
push:
branches: [ main ]
env:
DOCKER_IMAGE: ghcr.io/${{ github.actor }}/ossp_flaskapp
VERSION: ${{ github.sha }}
NAME: ossprac_container
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: Check out source code
uses: actions/checkout@v2
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.VERSION }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest
deploy:
needs: build
name: Deploy
runs-on: [ self-hosted, label-go ]
steps:
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Docker run
run: |
docker stop ${{ env.NAME }} && docker rm ${{ env.NAME }} && docker rmi ${{ env.DOCKER_IMAGE }}:latest
docker run -d -p 80:80 --name ossprac_container --restart always ${{ env.DOCKER_IMAGE }}:latest