This action determines the Docker tag based on what git branch, git tag or git commit you are on.
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> | 
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. | 
| Output | Description | 
|---|---|
| docker-tag | The determined Docker tag name. | 
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 }}The following Docker images will be pushed:
| Git state | Docker images | 
|---|---|
| On branch master | cytopia/php:8.0cytopia/php:8.1 | 
| On branch release-0.1 | cytopia/php:8.0-release-0.1cytopia/php:8.1-release-0.1 | 
| On tag v1.0.0 | cytopia/php:8.0-v1.0.0cytopia/php:8.1-v1.0.0 | 
| On commit 1aaf12a472ac794d00b75b826db4d223c3ef2d96 | cytopia/php:8.0-1aaf12acytopia/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 }}Copyright (c) 2022 cytopia