Skip to content

fix: tagging

fix: tagging #65

name: Docker
on:
push:
branches:
- gcc/*
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/caentainer-gcc
jobs:
push:
runs-on: self-hosted
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Generate Image Tag
id: image-tag
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[ "$VERSION" == "main" ] && VERSION=latest
echo VERSION=$VERSION
echo "::set-output name=TAG::${VERSION}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.image-tag.outputs.TAG }}
type=ref,event=branch
type=ref,event=tag
- name: Log into GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}-buildcache
cache-to: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}-buildcache,mode=max
platforms: linux/amd64
build-args: |
GITHUB_SHA=${{ github.sha }}
GITHUB_RUN_ID=${{ github.run_id }}
GITHUB_SERVER_URL=${{ github.server_url }}
GITHUB_REPOSITORY=${{ github.repository }}