Repository name must be lowercase

Hello! I’m a student and I’m studying in GitHub Actions with using Docker.
When I build and push codes at GitHub, there was a problem.

the problem is below:

I googled and recognized that my username made a problem, because my username ‘SEOLLLL’ is uppercase.

To solve this problem, I found that need to change my username or fix yml code.
But I cannot change my username because it is related to my school class.
So I have to change yml code that is given by my teacher but I don’t know how to fix it ;-;

Please help me ;-;

The yml code is below

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

The error complains about the value of DOCKER_IMAGE which contains the original uppercase username. Have you tried using the OWNER_LC environment variable you are creating?

env:
  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}
          echo "DOCKER_IMAGE=ghcr.io/$OWNER_LC/ossp_flaskapp" >>${GITHUB_ENV}
        env:
          OWNER: '${{ github.repository_owner }}'
      # ...
      - 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

Or if you need to use the github.actor value:

env:
  VERSION: ${{ github.sha }}
  NAME: ossprac_container   

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: set lower case owner name
        run: |
          echo "ACTOR_LC=${ACTOR,,}" >>${GITHUB_ENV}
          echo "DOCKER_IMAGE=ghcr.io/$ACTOR_LC/ossp_flaskapp" >>${GITHUB_ENV}
        env:
          ACTOR: '${{ github.actor }}'
      # ...
      - 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

That won’t work, because variables written to GITHUB_ENV will only be available starting from the next step. You can either split that into two steps, or just use the shell expression directly if you don’t need OWNER_LC elsewhere:

        run: |
          echo "DOCKER_IMAGE=ghcr.io/${OWNER,,}/ossp_flaskapp" >>${GITHUB_ENV}
3 Likes