PaaS/CI CD

Github Actions) Workflow 자동실행 조건에 Tag와 Branch 모두 걸기

armyost 2024. 2. 20. 23:25
728x90

이놈의 Workflow가 하나의 Commit의 일부이다 보니까, 여기저기 Branch에서 조건만 맞으면 돌아간다..

 

Tag조건이 원래 아래와 같은데 이게 문제가.. Branch안따지고 걍 Tag push하면 돌아간다는거다..

on:
  push:
    tags:
      - 'v*'

 

그래서 Tag를 붙이는 Target이랑 같이 And 조건을 걸면 훨씬 안정적인데, 이게 쉽지 않다. 결국 Release condition으로 가야한다. 

on:
  workflow_dispatch:
  release:
    types: [published]

jobs:
  deploy:
    if: github.event.release.target_commitish == 'prod'
    uses: ./.github/workflows/deploy-application.yaml

 

if조건으로 target에 대한 필터를 걸어준다. 그러면 target branch가 다르면 실행되다 만다.