actions-netlify: Can't use to Publish using Release Trigger Event

Desired Behavior

Be able to Deploy and Publish when using with a Release Trigger Event

What is happening

Hi I tried to use it for a Release Action Event to Deploy + Publish in Netlify. But because the isDraft is always true, It will never publish.

on:
  release:
    types: [published]

The isDraft is always true when using with a Release Action Event because of this condition const isDraft: boolean = context.ref !== refs/heads/${productionBranch}

Suggestion

I have a hotfix but I don’t have permissions to push a branch and open a PR. Could you give me the permission? If not, can you add this to the conidtion

// isDraft = true WHEN
// github.ref != production_branch
// OR
// github.ref CONTAINS tags AND github.event.release.draft == false  (This condition allow us to deploy + publish when it is on a release event)
const isDraft: boolean = context.ref !== `refs/heads/${productionBranch}` || (context.ref.includes('tags') && !context.ref.event.release.draft)

The contex.ref.event.release.draft I got from this doc: Events Object

And to check the context.ref for a release I just printed it with echo image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 26 (14 by maintainers)

Most upvoted comments

Hi, I was running into the same issue so I tried to implement this option in https://github.com/nwtgck/actions-netlify/pull/188

Do you know anything about it? I only used the free version.

I don’t know and I had paid before but I switched free plan now.


They call it Production but it is the only branch you can configure. Why would you put a name on it if it is the only option.

Maybe “only option”, but I may understand Netlify and what Netlify means. Netlify deploys every branch, not only “master”. That is a strong advantage of Netlify comparing with other static deployment service such as GitHub Pages. Ever branch is deployed with a prefix. For example, if piping-ui.netlify.app is “production”. Netlify deploys other branches with prefixes as follows.

To distinguish those branches, I guess Netlify uses “production branch”.

@AllanOricil

Release is not for a branch. Is when you want to release something to Production.

Yes. I think so too. My previous comment is about name of option/flag to solve this issue. So I was thinking about what better name is. How about the following input name and usage?

with:
  production-deploy: ${{ some condition }} 

Authors can specify any condition not only release trigger event by Context and expression syntax. (ref: https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions)

@nwtgck will have more to say but I think this Production branch concept is really a just a netlify thing. I don’t think it’s a concept that is really useful for production environments but it is what it is! I do think the production-branch option should be better documented though since it’s not very clear to users of this action what this option actually does.

Thanks @jsmith .

Idea 3

$ACTIONS_NETLIFY_PRODUCTION_DEPLOY env variable. When $ACTIONS_NETLIFY_PRODUCTION_DEPLOY exists, production-deployment is always triggered. This is also general solution for production-deployment.

I prefer to use general solution to avoid increasing options or inputs for future flexibility and composability. I believe decreasing options or inputs will contribute decreasing bugs.

Not the OP but I think the first idea would be great! It seems like it would be very easy to implement and would suite my needs perfectly 😃