0

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: enter image description here

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 ;-;

How should I change the code to build it well? ;-;

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
SEOI HONG
  • 1
  • 1
  • Github usernames are not case sensitive, you don't need to change your username, just use the lower case version of it. IE: this link works just fine: https://github.com/seollll/ossprac-web1 – Ron Beyer Nov 23 '21 at 03:26
  • welcome to SO, SEOI HONG. it looks like your YAML contains a lot of code that is irrelevant for your question and the formatting is off. your chances of getting help are much higher if you reduce the YAML to a minimal example that shows your problem. – rethab Nov 23 '21 at 07:57

1 Answers1

0

I recommend to use an action to convert the repository name to lowercase.

Here's an example taken from Change String Case action:

name: SomeWorkflow
on: [push]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - id: string
        uses: ASzc/change-string-case-action@v2
        with:
          string: XyZzY
      - id: step2
        run: echo ${{ steps.string.outputs.lowercase }}