본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

GitHub Actions로 태그·레이블 관리하기

원문 보기 위키 갱신

GitHub Actions로 태그·레이블 관리하기 (Manage tags and labels with GitHub Actions)

"자동적인" 태그 관리와 OCI Image Format Specification에 따른 레이블을 원한다면, 전용 setup 단계에서 처리할 수 있어요. 다음 워크플로는 Docker Metadata Action을 사용해 GitHub Actions 이벤트와 Git 메타데이터를 기반으로 태그와 레이블을 처리해요:

출처: 문서

본문

name: ci

on:
  schedule:
    - cron: "0 10 * * *"
  push:
    branches:
      - "**"
    tags:
      - "v*.*.*"
  pull_request:

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v6
        with:
          # 태그의 기본 이름으로 사용할 Docker 이미지 목록
          images: |
            name/app
            ghcr.io/username/app
          # 다음 이벤트/속성을 기반으로 Docker 태그 생성
          tags: |
            type=schedule
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha

      - name: Login to Docker Hub
        if: github.event_name != 'pull_request'
        # ...

metadata-action은 schedule, ref(브랜치/PR), semver(버전 패턴), sha 등 다양한 태그 타입을 지원해요. 이렇게 만들어진 tags와 labels 출력을 이후 빌드 단계에서 사용할 수 있어요.

더 알아보기 (Learn more)