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

Tags for branch names containing "#" parsed incorrectly ignoring the "#" #199

Closed
vajahath opened this issue May 1, 2022 · 1 comment · Fixed by #201
Closed

Tags for branch names containing "#" parsed incorrectly ignoring the "#" #199

vajahath opened this issue May 1, 2022 · 1 comment · Fixed by #201

Comments

@vajahath
Copy link

vajahath commented May 1, 2022

Behaviour

When I run metadata for on my branch banner-utils-test-#5 gives me a tag of: banner-utils-test--5. Is this expected?

JSON output
  {
    "tags": [
      "ghcr.io/xxx/xxx:banner-utils-test--5" 👈
    ],
    "labels": {
      "org.opencontainers.image.title": "xxx",
      "org.opencontainers.image.description": "Thing related to xxx",
      "org.opencontainers.image.url": "https://github.com/xxx/xxx",
      "org.opencontainers.image.source": "https://github.com/xxx/xxx",
      "org.opencontainers.image.version": "banner-utils-test--5",👈
      "org.opencontainers.image.created": "2022-04-29T09:30:00.228Z",
      "org.opencontainers.image.revision": "xxxx",
      "org.opencontainers.image.licenses": ""
    }
  }

Relevant actions/checkout logs for the branch info:

Checking out the ref
  /usr/bin/git checkout --progress --force -B banner-utils-test-#5 refs/remotes/origin/banner-utils-test-#5 👈
  Switched to a new branch 'banner-utils-test-#5'
  branch 'banner-utils-test-#5' set up to track 'origin/banner-utils-test-#5'. 👈
/usr/bin/git log -1 --format='%H'
'0f74d16753f11edb247f21e16e9be6d80ed3b387'

Steps to reproduce this issue

Try on a branch like xxxx-xx-#3

Expected behaviour

I don't know if this is the intended behaviour.
banner-utils-test-#5 should translate to it self instead of banner-utils-test--5

Configuration

name: build-test
on: [push]
jobs:
  Lint-Build-UnitTest:
    runs-on: ubuntu-latest
    env:
      REGISTRY: ghcr.io
      IMAGE_NAME: ${{ github.repository }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "16"

      - name: npm ci (normal) on ./functions - fast
        run: npm ci --no-audit --progress=false
        working-directory: ./functions

      - name: prettier
        run: npm run prettier

      - name: lint
        run: npm run lint

      - name: build
        run: npm run build

      - name: unit-test
        run: npm run test:unit

      - name: Delete dev node_modules
        run: rm -rf node_modules
        working-directory: ./functions

      - name: npm ci --prod on ./functions - fast
        run: npm ci --production --no-audit --progress=false
        working-directory: ./functions

      # docker starting
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels) for Docker 👈
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }} 👈
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=registry,ref=${{ steps.meta.outputs.tags }}
          cache-to: type=inline

  Integration-Test:
    runs-on: ubuntu-latest
    needs: Lint-Build-UnitTest
    container:
      image: node:16.13.2-slim
      env:
        GCLOUD_PROJECT: demo-friendly-octopus-u4st7gxr8
        FIRESTORE_EMULATOR_HOST: firebase_emulator:8080
        FIREBASE_STORAGE_EMULATOR_HOST: firebase_emulator:9199
        FIREBASE_AUTH_EMULATOR_HOST: firebase_emulator:9099
        MONGO_DB_URI: mongodb://mongodb:27017

    services:
      firebase_emulator:
        image: ghcr.io/xxxx/xxxx:${{ github.ref_name }}
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
          AVOID_FUNCTIONS_EMULATION: "yes"
      
      mongodb:
        image: mongo
        env:
          MONGO_INITDB_DATABASE: Friendly

    steps:
      - uses: actions/checkout@v2

      - name: fresh npm ci
        run: npm ci --no-audit --progress=false
        working-directory: ./functions

      - name: build
        run: npm run build
        working-directory: ./functions

      - name: Integration Test
        run: npm run test:integration
@crazy-max
Copy link
Member

@vajahath Yes this is quite similar to #56 (comment) and #189.

TLDR; tags are sanitized to replace unsupported char sequences with -: https://docs.docker.com/engine/reference/commandline/tag/#extended-description

A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes.

I will update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants