iaingalloway / devcontainers

Pre-built devcontainer images
MIT License
0 stars 0 forks source link

Tag devcontainers with gitversion #8

Closed iaingalloway closed 1 year ago

iaingalloway commented 1 year ago

On complicating factor is that the docker metadata action appears to split out tags separated by newlines

https://github.com/iaingalloway/gitversion-prototype/actions/runs/6677007276/job/18146608120

Docker tags
  ghcr.io/iaingalloway/gitversion-prototype:main
  ghcr.io/iaingalloway/gitversion-prototype:latest
  ghcr.io/iaingalloway/gitversion-prototype:1.13.2
  ghcr.io/iaingalloway/gitversion-prototype:1.13
  ghcr.io/iaingalloway/gitversion-prototype:1
  ghcr.io/iaingalloway/gitversion-prototype:1.13.2.main-2-cf1659b
  ghcr.io/iaingalloway/gitversion-prototype:1.13.2.main-2-cf1659bdf0d5a06334f8d2035ff55c0f17042d49

and

with:
    file: src/Dockerfile
    push: true
    tags: ghcr.io/iaingalloway/gitversion-prototype:main
  ghcr.io/iaingalloway/gitversion-prototype:latest
  ghcr.io/iaingalloway/gitversion-prototype:1.1[3](https://github.com/iaingalloway/gitversion-prototype/actions/runs/6677007276/job/18146608120#step:8:3).2
  ghcr.io/iaingalloway/gitversion-prototype:1.13
  ghcr.io/iaingalloway/gitversion-prototype:1
  ghcr.io/iaingalloway/gitversion-prototype:1.13.2.main-2-cf1659b
  ghcr.io/iaingalloway/gitversion-prototype:1.13.2.main-2-cf1659bdf0d5a0633
iaingalloway commented 1 year ago
    - name: Determine image tags using Docker metadata action
      id: meta
      uses: docker/metadata-action@v5
      with:
        images: ghcr.io/${{ github.repository }}
        tags: |
          type=raw,value=latest,enable=${{ startsWith(github.ref, github.event.repository.default_branch) }}
          type=ref,event=branch
          type=ref,event=pr
          type=raw,value=${{ steps.gitversion.outputs.semVer }},enable=${{ startsWith(github.ref, github.event.repository.default_branch) }}
          type=raw,value=${{ steps.gitversion.outputs.major }}.${{ steps.gitversion.outputs.minor }},enable=${{ startsWith(github.ref, github.event.repository.default_branch) }}
          type=raw,value=${{ steps.gitversion.outputs.major }},enable=${{ steps.gitversion.outputs.major != '0' }},enable=${{ startsWith(github.ref, github.event.repository.default_branch) }}
          type=raw,value=${{ steps.gitversion.outputs.semVer }}.${{ steps.gitversion.outputs.branchName }}-${{ steps.gitversion.outputs.commitsSinceVersionSource }}-{{sha}}
          type=raw,value=${{ steps.gitversion.outputs.semVer }}.${{ steps.gitversion.outputs.branchName }}-${{ steps.gitversion.outputs.commitsSinceVersionSource }}-${{ steps.gitversion.outputs.sha }}
          type=raw,value=${{ steps.gitversion.outputs.major }}.${{ steps.gitversion.outputs.minor }}-${{ steps.component-name.outputs.name }}${{ steps.component-version.outputs.version }},enable=${{ startsWith(github.ref, github.event.repository.default_branch) && steps.component-version.outputs.version-found == 'true' }}
          type=raw,value=${{ steps.gitversion.outputs.major }},enable=${{ steps.gitversion.outputs.major != '0' }}-${{ steps.component-name.outputs.name }}${{ steps.component-version.outputs.version }},enable=${{ startsWith(github.ref, github.event.repository.default_branch) && steps.component-version.outputs.version-found == 'true' }}
          type=raw,value=${{ steps.gitversion.outputs.semVer }}.${{ steps.gitversion.outputs.branchName }}-${{ steps.gitversion.outputs.commitsSinceVersionSource }}-{{sha}}-${{ steps.component-name.outputs.name }}${{ steps.component-version.outputs.version }},enable=${{ steps.component-version.outputs.version-found == 'true' }}
          type=raw,value=${{ steps.gitversion.outputs.semVer }}.${{ steps.gitversion.outputs.branchName }}-${{ steps.gitversion.outputs.commitsSinceVersionSource }}-${{ steps.gitversion.outputs.sha }}-${{ steps.component-name.outputs.name }}${{ steps.component-version.outputs.version }},enable=${{ steps.component-version.outputs.version-found == 'true' }}

    - name: Build devcontainer
      uses: devcontainers/ci@v0.3
      with:
        imageName: ${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image }}
        imageTag: ${{ join(fromJson(steps.meta.outputs.json).tags, ',') }}
        subFolder: ./src/devcontainers/${{ inputs.image }}
        cacheFrom: ${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image }}