https://github.com/cssnr/docker-tags-action
Generate Docker Tags and Labels for building Docker images with GitHub Actions.
https://github.com/cssnr/docker-tags-action
actions
Last synced: 18 days ago
JSON representation
Generate Docker Tags and Labels for building Docker images with GitHub Actions.
- Host: GitHub
- URL: https://github.com/cssnr/docker-tags-action
- Owner: cssnr
- License: gpl-3.0
- Created: 2024-07-02T22:08:10.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T00:11:38.000Z (over 1 year ago)
- Last Synced: 2025-02-18T00:26:57.389Z (over 1 year ago)
- Topics: actions
- Language: JavaScript
- Homepage: https://cssnr.github.io
- Size: 428 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/cssnr/docker-tags-action/tags)
[](https://github.com/cssnr/docker-tags-action/releases)
[](https://github.com/cssnr/docker-tags-action/releases/latest)
[](https://github.com/cssnr/docker-tags-action/blob/master/src/index.js)
[](https://github.com/cssnr/docker-tags-action/blob/master/action.yml)
[](https://github.com/cssnr/docker-tags-action/actions/workflows/release.yaml)
[](https://github.com/cssnr/docker-tags-action/actions/workflows/test.yaml)
[](https://github.com/cssnr/docker-tags-action/actions/workflows/lint.yaml)
[](https://sonarcloud.io/summary/new_code?id=cssnr_docker-tags-action)
[](https://github.com/cssnr/docker-tags-action/pulse)
[](https://codeberg.org/cssnr/docker-tags-action)
[](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
[](https://github.com/cssnr/docker-tags-action)
[](https://github.com/cssnr/docker-tags-action/graphs/contributors)
[](https://github.com/cssnr/docker-tags-action/discussions)
[](https://github.com/cssnr/docker-tags-action/forks)
[](https://github.com/cssnr/docker-tags-action/stargazers)
[](https://cssnr.github.io/)
[](https://discord.gg/wXy6m2X8wY)
[](https://ko-fi.com/cssnr)
# Docker Tags Action
- [Inputs](#Inputs)
- [Tags](#docker-tags)
- [Labels](#docker-labels)
- [Outputs](#Outputs)
- [Examples](#Examples)
- [Tags](#Tags)
- [Support](#Support)
- [Contributing](#Contributing)
Generate Docker Tags and Labels for building Docker images with GitHub Actions.
For a more detailed implementation see: https://github.com/docker/metadata-action
> [!NOTE]
> Please submit a [Feature Request](https://github.com/cssnr/docker-tags-action/discussions/categories/feature-requests)
> for new features or [Open an Issue](https://github.com/cssnr/docker-tags-action/issues) if you find any bugs.
## Inputs
| Input | Default Value | Description of the Input Value |
| :----------------------- | :--------------------------------- | :------------------------------------------------- |
| images | `ghcr.io/${{ github.repository }}` | Images for Tag Generation, CSV or Newline |
| [tags](#docker-tags) | _[see tags](#docker-tags)_ | Extra Tags to Generate, CSV or Newline |
| [labels](#docker-labels) | _[see labels](#docker-labels)_ | Extra Labels to Generate, CSV or Newline |
| [seperator](#seperator) | `\n` | Output Seperator |
| [latest](#latest) | `default` | Latest Tag: [`true`, `false`, `default`] |
| [summary](#summary) | `true` | Add Summary to Job |
This works with no inputs, but you can customize the resulting tags and labels with inputs.
```yaml
- name: 'Docker Tags'
id: tags
uses: cssnr/docker-tags-action@v2
```
### seperator
Output seperator. Newline is default and that works as the input for the docker build actions.
### latest
Default behavior only adds `latest` tag to a release that are not a pre-release.
### summary
Write a Summary for the job. To disable this set to `false`.
👀 View Example Summary
---
Generated **2** Tags and **8** Labels for **1** Images. Parsed ref: `pr-6`
Docker Tags
ghcr.io/cssnr/docker-tags-action:pr-6
ghcr.io/cssnr/docker-tags-action:latest
Docker Labels
org.opencontainers.image.created=2025-02-20T02:33:28.010Z
org.opencontainers.image.revision=fb2319bda85e745c78981bc0ec6b316f07b602b5
org.opencontainers.image.source=https://github.com/cssnr/docker-tags-action
org.opencontainers.image.title=docker-tags-action
org.opencontainers.image.url=https://github.com/cssnr/docker-tags-action
org.opencontainers.image.version=pr-6
org.opencontainers.image.description=Generate Docker Tags and Labels for building Docker images with GitHub Actions.
org.opencontainers.image.authors=smashedr
InputsInputValueimagesghcr.io/cssnr/docker-tags-actiontagslabelsorg.opencontainers.image.licenses=,org.opencontainers.image.authors=smashedrseperator"\n"latesttruesummarytrue
---
To view a workflow run, click on a recent [Test](https://github.com/cssnr/docker-tags-action/actions/workflows/test.yaml) job _(requires login)_.
### docker tags
| Event | Ref | Tags |
| :---------------- | :------------------ | :------- |
| `tag` / `release` | `refs/tags/v1.0.0` | `v1.0.0` |
| `push` / `other` | `refs/heads/master` | `master` |
| `pull_request` | `refs/pull/1/merge` | `pr-1` |
This is the default tag added which is also set as the version for the label.
Coming Soon: Add an option called `default` to disable or override the default tag.
### docker labels
```shell
org.opencontainers.image.description=Example Repository Description
org.opencontainers.image.revision=32b96cee5b4e940b4023f78261702470d59c8001
org.opencontainers.image.source=https://github.com/cssnr/docker-tags-action
org.opencontainers.image.title=repository-name
org.opencontainers.image.url=https://github.com/cssnr/docker-tags-action
org.opencontainers.image.version=v1.0.0
org.opencontainers.image.licenses=GPL-3.0
```
These are the default labels. You can add them or remove them by providing a key with no value.
The description and license are only added if they are defined on your repository.
Example removing `org.opencontainers.image.licenses` and adding `org.opencontainers.image.authors`.
```yaml
labels: |
org.opencontainers.image.licenses=
org.opencontainers.image.authors=smashedr
```
## Outputs
| Output | Output Description |
| :---------- | :---------------------- |
| tags | Generated Tags |
| labels | Generated Labels |
| annotations | Generated Annotations |
All outputs are seperated by the inputs `seperator` which defaults to a newline.
```yaml
- name: 'Docker Tags'
id: tags
uses: cssnr/docker-tags-action@v2
- name: 'Echo Result'
run: |
echo -e "tags: \n${{ steps.tags.outputs.tags }}"
echo -e "labels: \n${{ steps.tags.outputs.labels }}"
echo -e "annotations: \n${{ steps.tags.outputs.annotations }}"
```
## Examples
With all inputs:
```yaml
- name: 'Docker Tags'
id: tags
uses: cssnr/docker-tags-action@v2
with:
images: 'ghcr.io/${{ github.repository }}'
tags: v1,v1.0
labels: |
org.opencontainers.image.licenses=
org.opencontainers.image.authors=smashedr
seperator: ','
latest: true
```
Full Example:
```yaml
name: 'Release'
on:
release:
types: [published]
jobs:
build:
name: 'Build'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
packages: write
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Docker Tags'
id: tags
uses: cssnr/docker-tags-action@v2
with:
images: 'ghcr.io/${{ github.repository }}'
tags: ${{ github.ref_name }}
latest: false
- name: 'Echo Tags'
run: |
echo -e "tags: \n${{ steps.tags.outputs.tags }}"
echo -e "labels: \n${{ steps.tags.outputs.labels }}"
- name: 'Docker Login'
uses: docker/login-action@v3
with:
registry: 'ghcr.io'
username: ${{ vars.GHCR_USER }}
password: ${{ secrets.GHCR_PASS }}
- name: 'Setup Buildx'
uses: docker/setup-buildx-action@v3
- name: 'Build and Push'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.tags.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
```
To see this used in a release workflow, see: https://github.com/cssnr/cloudflare-purge-cache-action/blob/master/.github/workflows/release.yaml
For more examples, you can check out other projects using this action:
https://github.com/cssnr/docker-tags-action/network/dependents
## Tags
The following rolling [tags](https://github.com/cssnr/docker-tags-action/tags) are maintained.
| Version Tag | Rolling | Bugs | Feat. | Name | Target | Example |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :--: | :---: | :-------: | :------: | :------- |
| [](https://github.com/cssnr/docker-tags-action/releases/latest) | ✅ | ✅ | ✅ | **Major** | `vN.x.x` | `vN` |
| [](https://github.com/cssnr/docker-tags-action/releases/latest) | ✅ | ✅ | ❌ | **Minor** | `vN.N.x` | `vN.N` |
| [](https://github.com/cssnr/docker-tags-action/releases/latest) | ❌ | ❌ | ❌ | **Micro** | `vN.N.N` | `vN.N.N` |
You can view the release notes for each version on the [releases](https://github.com/cssnr/docker-tags-action/releases) page.
The **Major** tag is recommended. It is the most up-to-date and always backwards compatible.
Breaking changes would result in a **Major** version bump. At a minimum you should use a **Minor** tag.
# Support
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/docker-tags-action/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/docker-tags-action/discussions/categories/feature-requests
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/docker-tags-action/issues
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
- Provide General Feedback: [https://cssnr.github.io/feedback/](https://cssnr.github.io/feedback/?app=Update%20JSON%20Value)
For more information, see the CSSNR [SUPPORT.md](https://github.com/cssnr/.github/blob/master/.github/SUPPORT.md#support).
# Contributing
If you would like to submit a PR, please review the [CONTRIBUTING.md](#contributing-ov-file).
Please consider making a donation to support the development of this project
and [additional](https://cssnr.com/) open source projects.
[](https://ko-fi.com/cssnr)
[](https://actions-tools.cssnr.com/)
Additionally, you can support other [GitHub Actions](https://actions.cssnr.com/) I have published:
- [Stack Deploy Action](https://github.com/cssnr/stack-deploy-action?tab=readme-ov-file#readme)
- [Portainer Stack Deploy Action](https://github.com/cssnr/portainer-stack-deploy-action?tab=readme-ov-file#readme)
- [Docker Context Action](https://github.com/cssnr/docker-context-action?tab=readme-ov-file#readme)
- [Actions Up Action](https://github.com/cssnr/actions-up-action?tab=readme-ov-file#readme)
- [Zensical Action](https://github.com/cssnr/zensical-action?tab=readme-ov-file#readme)
- [VirusTotal Action](https://github.com/cssnr/virustotal-action?tab=readme-ov-file#readme)
- [Mirror Repository Action](https://github.com/cssnr/mirror-repository-action?tab=readme-ov-file#readme)
- [Update Version Tags Action](https://github.com/cssnr/update-version-tags-action?tab=readme-ov-file#readme)
- [Docker Tags Action](https://github.com/cssnr/docker-tags-action?tab=readme-ov-file#readme)
- [TOML Action](https://github.com/cssnr/toml-action?tab=readme-ov-file#readme)
- [Update JSON Value Action](https://github.com/cssnr/update-json-value-action?tab=readme-ov-file#readme)
- [JSON Key Value Check Action](https://github.com/cssnr/json-key-value-check-action?tab=readme-ov-file#readme)
- [Parse Issue Form Action](https://github.com/cssnr/parse-issue-form-action?tab=readme-ov-file#readme)
- [Cloudflare Purge Cache Action](https://github.com/cssnr/cloudflare-purge-cache-action?tab=readme-ov-file#readme)
- [Mozilla Addon Update Action](https://github.com/cssnr/mozilla-addon-update-action?tab=readme-ov-file#readme)
- [Package Changelog Action](https://github.com/cssnr/package-changelog-action?tab=readme-ov-file#readme)
- [NPM Outdated Check Action](https://github.com/cssnr/npm-outdated-action?tab=readme-ov-file#readme)
- [Label Creator Action](https://github.com/cssnr/label-creator-action?tab=readme-ov-file#readme)
- [Algolia Crawler Action](https://github.com/cssnr/algolia-crawler-action?tab=readme-ov-file#readme)
- [Upload Release Action](https://github.com/cssnr/upload-release-action?tab=readme-ov-file#readme)
- [Check Build Action](https://github.com/cssnr/check-build-action?tab=readme-ov-file#readme)
- [Web Request Action](https://github.com/cssnr/web-request-action?tab=readme-ov-file#readme)
- [Get Commit Action](https://github.com/cssnr/get-commit-action?tab=readme-ov-file#readme)
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- [cssnr/create-files-action](https://github.com/cssnr/create-files-action?tab=readme-ov-file#readme) - Create various files from templates.
- [cssnr/draft-release-action](https://github.com/cssnr/draft-release-action?tab=readme-ov-file#readme) - Keep a draft release ready to publish.
- [cssnr/env-json-action](https://github.com/cssnr/env-json-action?tab=readme-ov-file#readme) - Convert env file to json or vice versa.
- [cssnr/push-artifacts-action](https://github.com/cssnr/push-artifacts-action?tab=readme-ov-file#readme) - Sync files to a remote host with rsync.
- [smashedr/update-release-notes-action](https://github.com/smashedr/update-release-notes-action?tab=readme-ov-file#readme) - Update release notes.
- [smashedr/combine-release-notes-action](https://github.com/smashedr/combine-release-notes-action?tab=readme-ov-file#readme) - Combine release notes.
---
📝 Template Actions
These are basic action templates that I use for creating new actions.
- [javascript-action](https://github.com/smashedr/javascript-action?tab=readme-ov-file#readme) - JavaScript
- [typescript-action](https://github.com/smashedr/typescript-action?tab=readme-ov-file#readme) - TypeScript
- [py-test-action](https://github.com/smashedr/py-test-action?tab=readme-ov-file#readme) - Dockerfile Python
- [test-action-uv](https://github.com/smashedr/test-action-uv?tab=readme-ov-file#readme) - Dockerfile Python UV
- [docker-test-action](https://github.com/smashedr/docker-test-action?tab=readme-ov-file#readme) - Docker Image Python
Note: The `docker-test-action` builds, runs and pushes images to [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
---
For a full list of current projects visit: [https://cssnr.github.io/](https://cssnr.github.io/)