'Repository name must be lowercase
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
Solution 1:[1]
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 }}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jorge Massih |