Skip to content

Latest commit

 

History

History
171 lines (124 loc) · 6.86 KB

README.md

File metadata and controls

171 lines (124 loc) · 6.86 KB

Docker tag action

GitHub release GitHub marketplace test

This composite action determines the Docker tag based on what git branch, git tag or git commit you are on.

🔃 Determination

The Docker tag output (docker-tag) of this action is determined in its default configuration as shown by the following table:

Git state Resulting Docker tag
On branch master latest
On another branch <branch-name>
On a tag <tag-name>
Detached commit <git-commit-hash>

▶️ Inputs

The following inputs can be used to alter the Docker tag name determination:

Input Required Default Description
latest_git_branch No master Optionally change the git branch, which determines the the Docker tag latest.
latest_docker_tag_name No latest Optionally specify an alternative Docker tag name for latest.
non_latest_docker_tag_prefix No `` Optionally add a prefix to all non-latest docker tags.
non_latest_docker_tag_suffix No `` Optionally add a suffix to all non-latest docker tags.

◀️ Outputs

Output Description
docker-tag The determined Docker tag name.

💻 Usage

Basic

The following Docker images will be pushed:

Git state Docker images
On branch master cytopia/php:latest
On branch release-0.1 cytopia/php:release-0.1
On tag v1.0.0 cytopia/php:v1.0.0
On commit 1aaf12a472ac794d00b75b826db4d223c3ef2d96 cytopia/php:1aaf12a
on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy docker image
    steps:

      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Set Docker tag
        id: tag
        uses: cytopia/[email protected]

      - name: build
        run: |
          docker build -t cytopia/php:${{ steps.tag.outputs.docker-tag }} .

      - name: push
        run: |
          docker push cytopia/php:${{ steps.tag.outputs.docker-tag }}

Matrix

The following Docker images will be pushed:

Git state Docker images
On branch master cytopia/php:8.0
cytopia/php:8.1
On branch release-0.1 cytopia/php:8.0-release-0.1
cytopia/php:8.1-release-0.1
On tag v1.0.0 cytopia/php:8.0-v1.0.0
cytopia/php:8.1-v1.0.0
On commit 1aaf12a472ac794d00b75b826db4d223c3ef2d96 cytopia/php:8.0-1aaf12a
cytopia/php:8.1-1aaf12a
on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy docker image
    strategy:
      fail-fast: false
      matrix:
        version:
          - '8.0'
          - '8.1'
    steps:

      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Set Docker tag
        id: tag
        uses: cytopia/[email protected]
        with:
          latest_git_branch: master
          latest_docker_tag_name: ${{ matrix.version }}
          non_latest_docker_tag_prefix: "${{ matrix.version }}-"

      - name: build
        run: |
          docker build -t cytopia/php:${{ steps.tag.outputs.docker-tag }} .

      - name: push
        run: |
          docker push cytopia/php:${{ steps.tag.outputs.docker-tag }}

❗ Keep up-to-date with GitHub Dependabot

Since Dependabot has native GitHub Actions support, to enable it on your GitHub repo all you need to do is add the .github/dependabot.yml file:

version: 2
updates:
  # Maintain dependencies for GitHub Actions
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"

:octocat: cytopia GitHub Actions

Name Description
docker-tag-action Determines Docker tags based on git branch, commit or git tag
git-ref-matrix-action Create stringified JSON list of git refs to be used as a build matrix
shell-command-retry-action Retries shell commands to avoid failing pipelines due to network issues
upload-artifact-verify-action Upload artifact and verifies it by downloading it again
upload-artifact-retry-action Retries upload-artifact-verify-action
download-artifact-retry-action Download artifact with retry functionality

📄 License

MIT License

Copyright (c) 2022 cytopia