Skip to content

test "docker/metadata-action" #23

test "docker/metadata-action"

test "docker/metadata-action" #23

Workflow file for this run

name: Docker test
on:
push:
jobs:
docker:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache docker layers
if: ${{ !env.ACT }}
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.service }}
${{ runner.os }}-buildx-
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
mcuadros/ofelia
ghcr.io/${{ github.repository }}
flavor: |
latest=false
tags: |
type=raw,value=development,enable=${{ github.event_name != 'release' }}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
- name: Print
run: cat ${{ steps.meta.outputs.bake-file }}
- name: Prepare version number
id: prepare
run: |
VERSION=$(git describe --always --tags)
if [ "${{ github.event_name }}" = "release" ]; then
TAGS="mcuadros/ofelia:$VERSION,mcuadros/ofelia:latest"
# Replace with below once @mcuadros adds the DOCKER_USERNAME secret
#TAGS="${{secrets.DOCKER_USERNAME}}/ofelia:$VERSION,${{secrets.DOCKER_USERNAME}}/ofelia:latest"
else
TAGS="mcuadros/ofelia:$VERSION,mcuadros/ofelia:development"
# Replace with below once @mcuadros adds the DOCKER_USERNAME secret
#TAGS="${{secrets.DOCKER_USERNAME}}/ofelia:$VERSION,${{secrets.DOCKER_USERNAME}}/ofelia:development"
fi
echo ::set-output name=tags::${TAGS}
- name: Print
run: echo "${{ steps.meta.outputs.tags }}"
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: mcuadros
# Replace with below once @mcuadros adds the DOCKER_USERNAME secret
# username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}