ai-cfia / github-workflows

Reusable github workflows
MIT License
2 stars 0 forks source link

Handling Absence of Dockerfile in Workflow #132

Closed ThomasCardin closed 1 month ago

ThomasCardin commented 1 month ago

In the absence of a Dockerfile, we should simply remove the workflow from the directory. That being said, we could remove this problematic step from the workflow. In summary, if no Dockerfile was found, we performed an early exit. However, this early exit affected all workflows in the "run".

- name: Check if a Dockerfile is present at the root of the repo
  id: check-file
  run: |
    if [ -f Dockerfile ]; then
      echo "::set-output name=exists::true"
    else
      echo "::set-output name=exists::false"

- name: Early exit if no Dockerfile is present
  if: steps.check-file.outputs.exists == 'false'
  run: |
    gh run cancel ${{ github.run_id }}
    gh run watch ${{ github.run_id }}
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}