docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.11k stars 527 forks source link

context should observe working-directory defined on defaults #1030

Closed sombriks closed 6 months ago

sombriks commented 6 months ago

Description

currently i have a monorepo/multiprojec setup and a small action for each project.

for most actions, i set a working-directory so i can perform every action (npm install, checkout, etc) from that directory.

publish action does not observe this directory, always defaulting to repo root, so i need to set context regardless what i have on my working-direction.

see sample here.

crazy-max commented 6 months ago

No need for another input, you can just use the context input if you want to build from a subdir.

sombriks commented 6 months ago

what i am saying is there is a default section documented here: https://docs.github.com/en/actions/using-jobs/setting-default-values-for-jobs#example-set-the-default-shell-and-working-directory

and the action does not honor it.

i did exactly what you suggested but this is not what one could expect if there is a default setting for working-directory.

crazy-max commented 6 months ago

see sample here.

Your link returns a 404

sombriks commented 6 months ago

Here's a working one: https://github.com/sombriks/redline/blob/3b672a3064dc63a4ff513630e7fe435e9ea84904/.github/workflows/node.js-service.yml#L12

i set up working-directory: service-node-koa as a default and it is observed by Checkout Code, Use Node and Run tests steps with one caveat for npm cache but that's all. they all know the proper working directory by defaults settings.

For Build and Push step indeed set context solves the issue, and thinking again about that, the defaults section is specific to run commands. I think it's fine to set it like this in this monorepo/multiproject scenario.

crazy-max commented 6 months ago

Looking at the docs, working-directory only works for run: steps, not for actions: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsworking-directory