Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle upper-case organisation/repo-owner names in a better way #118

Closed
2 tasks
christian-kreuzberger-dtx opened this issue Apr 12, 2022 · 2 comments · Fixed by #131
Closed
2 tasks

Handle upper-case organisation/repo-owner names in a better way #118

christian-kreuzberger-dtx opened this issue Apr 12, 2022 · 2 comments · Fixed by #131
Assignees
Labels
good first issue Good for newcomers type:improvement Improves/enhances an existing feature

Comments

@christian-kreuzberger-dtx
Copy link
Contributor

christian-kreuzberger-dtx commented Apr 12, 2022

When using this template with a username that has uppercase characters, e.g., @Raffy23, we ended up getting problems when pushing to ghcr.io using the following workflow:

- name: Docker Build
id: docker_build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAGS: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
PUSH: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository)}}

This was partially addressed in keptn/gh-automation (see PRs #20, #18, #15), but it's still not a very satisfying solution as it adds complexity to keptn/gh-automation.

According to docker-build-push-action Troubleshooting, a better solution would be to sanitize the repo owner directly in your workflow:

- name: Sanitize repo owner
  uses: actions/github-script@v4
  id: repo_slug
  with:
    result-encoding: string
    script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Build and push
  uses: docker/build-push-action@v2
  with:
    context: .
    push: true
    tags: ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}

Definition of done

  • Sanitize repository_owner in all affected workflows in keptn-service-template-go, and use sanitized string instead of github.repository_owner
  • Proof that it works using upper-cased GitHub username and provide screenshots

Affected Workflows

@christian-kreuzberger-dtx christian-kreuzberger-dtx added good first issue Good for newcomers type:improvement Improves/enhances an existing feature labels Apr 12, 2022
@mehabhalodiya
Copy link

@christian-kreuzberger-dtx Can you please assign this to me?
Not an expert in GH actions though, I would like to help with some of your guidance. Thanks!

@christian-kreuzberger-dtx
Copy link
Contributor Author

@mehabhalodiya any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type:improvement Improves/enhances an existing feature
Projects
None yet
3 participants