GithubHelp home page GithubHelp logo

shrink / actions-docker-registry-tag Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 6.0 408 KB

:whale: Add many tags to an image in a Docker Registry

License: MIT License

TypeScript 94.16% JavaScript 5.84%
actions actions-docker docker-tag docker-tags docker-registry ghcr github-actions

actions-docker-registry-tag's Introduction

Docker Registry Tag

A GitHub Action for adding many tags to an existing image in a Docker Registry without changing the digest, using Docker Registry API V2.

- uses: shrink/actions-docker-registry-tag@v4
  with:
    registry: ghcr.io
    repository: ${{ github.repository }}
    target: sha-${{ github.sha }}
    tags: |
      v1.0.0
      latest

๐Ÿ“ฆ Automatic Release Packaging is used by this action, please reference by tag or commit hash in your Workflows.

Inputs

Token is an optional input for GitHub's Container Registry. Ensure the Actions token has permission to write to the package repository by granting access as described in "About GitHub Packages with GitHub Actions".

ID Description Examples
registry Registry API root domain ghcr.io index.docker.io
token Bearer token for the Registry API ${{ secrets.DOCKER_KEY }}
repository Image repository name shrink/example
target Tag of the existing image branch-name sha-1150f2f
tags Tag(s) to add to the target (new-line delimited) v1.0.1 latest

Outputs

No outputs.

Examples

Tag Image with Semantic Version

Add Semantic Version tag to a commit's image in registry when a new tag is pushed to the repository. The target image is assumed to have been tagged with sha-${{ github.sha }} on build.

name: Tag Image With Version

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  add-version-tag:
    runs-on: ubuntu-latest
    steps:
      - id: version
        uses: battila7/get-version-action@v2
      - name: Add Semantic Version tag to Docker Image
        uses: shrink/actions-docker-registry-tag@v4
        with:
          registry: ghcr.io
          repository: '${{ github.repository }}'
          target: 'sha-${{ github.sha }}'
          tags: '${{ steps.version.outputs.version }}'

Automatic Release Packaging

Packaging (creation of dist) happens automatically when a new tag is created. Any reference to this Action in a Workflow must use a tag (mutable) or the commit hash of a tag (immutable).

โœ… uses: shrink/actions-docker-registry-tag@v4
โœ… uses: shrink/[email protected]
โœ… uses: shrink/actions-docker-registry-tag@57e97909852876c02080eff4d73b2e5e779b845b
โŒ uses: shrink/actions-docker-registry-tag@main

The blog post Package GitHub Actions automatically with GitHub Actions describes how this achieved.

actions-docker-registry-tag's People

Contributors

derekroberts avatar mishraomp avatar shrink avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

actions-docker-registry-tag's Issues

Document tag edge-cases

Specifically I'm wondering:
Will adding tags replace existing tags on an image?
Will adding an existing tag fail?

Multi-architecture images cannot be re-tagged

This action works by downloading a digest for a tag and then uploading it again to a different tag, however multi-architecture images do not return a digest to the API call: they return a list (application/vnd.docker.distribution.manifest.list.v2+json). Docker's Registry v2 API does not currently support pushing a list of digests to a tag, we must push each tag individually.

Report errors returned in JSON response

As documented here the server returns error messages in the JSON response body. These should be reported to the user in addition to the generic failure message (<repository:tag> could not be tagged with <tag>).

Support OCI archives in registry

If an OCI image archive is in a registry, a request must explicitly opt-in to receive information about it by including it in the header.

Accept: application/vnd.oci.image.manifest.v1+json
  • Add debugging output when a request to the registry fails
  • Find out which accept headers are required to support all images
  • Add accept header for each of the above

Node 12 deprecation

Node 12 is out of support and deprecated by GitHub Actions with an end date of summer 2023. As of at least 2022-10-13 there have been deprecation warnings around using this Action. I'm hoping you upgrade. Thanks! :)

GitHub Release
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/

Deprecation warning:
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: shrink/actions-docker-registry-tag, actions/checkout

Remove `registry` from `repository` if included

Sometimes a user might not have the cleanest of input, i.e: they may have a full repository path (ghcr.io/shrink/example-image) and so when they provide registry or repository this action should identify that case and sanitise the input, so that user sdo not need to implement their own separate input validation.

Document how to obtain a Bearer token for Docker Hub

This may require an additional action, because it looks like the only way to generate a valid token is with an API request, the Docker Hub Personal Access Tokens do not seem to grant API access, they're just revokable passwords.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.