GithubHelp home page GithubHelp logo

nwtgck / actions-netlify Goto Github PK

View Code? Open in Web Editor NEW
314.0 3.0 42.0 38.39 MB

๐Ÿš€ Netlify deploy from GitHub Actions

License: MIT License

TypeScript 97.19% JavaScript 2.81%
netlify github-actions static-site deployment actions

actions-netlify's Introduction

actions-netlify

build-test

GitHub Actions for deploying to Netlify

Deploy URLs are commented on your pull requests and commit comments!

GitHub Deployments are also supported!

Usage

# .github/workflows/netlify.yml
name: Build and Deploy to Netlify
on:
  push:
  pull_request:
jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4

      # ( Build to ./dist or other directory... )

      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        with:
          publish-dir: './dist'
          production-branch: master
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-pull-request-comment: false
          enable-commit-comment: true
          overwrites-pull-request-comment: true
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

Required inputs and env

  • publish-dir (e.g. "dist", "_site")
  • NETLIFY_AUTH_TOKEN: Personal access tokens > New access token
  • NETLIFY_SITE_ID: team page > your site > Settings > Site details > Site information > API ID
    • NOTE: API ID is NETLIFY_SITE_ID.

Optional inputs

  • production-branch (e.g. "master")
  • production-deploy: Deploy as Netlify production deploy (default: false)
  • github-token: ${{ secrets.GITHUB_TOKEN }}
  • deploy-message A custom deploy message to see on Netlify deployment (e.g. ${{ github.event.pull_request.title }})
  • enable-pull-request-comment: true Comment on pull request (default: true)
  • enable-commit-comment: true Comment on GitHub commit (default: true)
  • enable-commit-status: true GitHub commit status (default: true)
  • overwrites-pull-request-comment: true Overwrites comment on pull request (default: true)
  • netlify-config-path: ./netlify.toml Path to netlify.toml (default: undefined)
  • functions-dir Netlify functions output directory (default: undefined)
  • alias Specifies the prefix for the deployment URL, must not have uppercase or special characters (default: Netlify build ID)
  • enable-github-deployment Whether or not to deploy to GitHub (default: true)
  • github-deployment-environment Environment name of GitHub Deployments
  • github-deployment-description Description of the GitHub Deployment
  • fails-without-credentials Fails if no credentials provided (default: false)

Paths are relative to the project's root

All paths (eg, publish-dir, netlify-config-path, functions-dir) are relative to the project's root or absolute paths.

Outputs

  • deploy-url A deployment URL generated by Netlify

Build on local

npm ci
npm run all

actions-netlify's People

Contributors

a-tokyo avatar deining avatar dependabot-preview[bot] avatar dependabot[bot] avatar fmr avatar github-actions[bot] avatar gvdp avatar imgbot[bot] avatar imgbotapp avatar kaisermann avatar kentaro-m avatar nielsbom avatar nojvek avatar nwtgck avatar ocavue avatar peaceiris avatar rajington avatar rstacruz avatar scopsy avatar south-paw avatar thepushkarp avatar tiangolo avatar ysndr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

actions-netlify's Issues

Deploy to additional branches

I am trying to use the action and it works great on Deploy Preview and Production.
But not in Staging branch, the issue is that although the deployment URL seems to be correct (since I use alias option), the environment code is not updated.

This is what I set up in my project settings in Netlify:

image

This is the code of the action:

- name: Deploy to Netlify
  uses: nwtgck/actions-netlify@v1
  env:
    NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
    NETLIFY_SITE_ID: ${{ env.NETLIFY_SITE_ID }}
  with:
    publish-dir: ${{ env.WORKING_DIRECTORY }}/dist
    production-branch: master
    github-token: ${{ secrets.READ_GITHUB_TOKEN }}
    github-deployment-environment: deploy preview
    enable-commit-comment: false
    deploy-message: ${{ env.SHORT_COMMIT_MESSAGE }}
    alias: ${{ env.GIT_BRANCH }}

I tried a lot of options but nothing helped and I would be very happy if you could help or advice. Thanks

GitHub Actions bot environment links expire

I'm using this to build deployment previews for pull requests. I have found that the GitHub Actions bot also puts an environment link on the PR whenever CI runs successfully. I find those links less distracting than having the bot actually comment a regular PR comment with the Netlify link. Hence, this is what I'm using as config:
https://github.com/grammyjs/website/blob/b3c08dedba6c2254912866c683621b847aa06084/.github/workflows/deno.yml#L32

However, even though the Netlify links are persistent, these environments seem to expire after a few hours (something between 1 and 5). Note that I don't mean old links after new activity. When the PR is inactive for a few hours, the bot somehow removes the link, AVE the message changes to "temporarily deployed to pull request". There's currently an example here: grammyjs/website#146

Is there any configuration I can use to prevent the bot from removing the links?

If there's no way, I'll just go back to having it comment regular text comments.

Feature Request: Add option for providing PR context (useful for `workflow_run`)

To get this action to work with non-collaborator PRs I am following the advice to move job steps that require secrets into a separate workflow_run workflow. I am providing the secrets to deploy, the build directory to publish and other field values that I can, this all works as expected.

The action is no longer able to add a comment, deployment environment status, check suite status (enable-commit-status), etc. enable-commit-comment appears to be working, but it is taking the commit/SHA from my master branch that the workflow_run is running from as it's not aware of my pull request anymore. This adds a deployment comment on a commit that is relevant to the pull request.

I use a different action to manage the PR comments. It has a number option to provide PR number (used if no pull_request event is found):

      - uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: preview
          number: ${{ env.PR_NUMBER }}
          message: |
            [Documentation preview for this PR](${{ steps.preview.outputs.deploy-url }}) is ready! :tada:

            Built with commit: ${{ env.PR_HEADSHA }}

By providing the PR number (transferred via artifact), I am able to get my comments updated again.


Personally I don't need this feature, but it might be beneficial to other users of your action?

This action may benefit from a similar pr_number feature? The only feature I am losing with my setup with workflow_run is the deployment status updates on the pull request, but the PR comment fulfills the same purpose.

The deployment options are still valid, the project activity log can be viewed to see that a new deployment is added, and a CLI API query lists the deployment description. The only incorrect part is the commit (my master commit instead of actual PR commit (pull_request.head.sha)), I have that information to provide the action with.

Add deploy numbers on Netlify

Deploys with github-action haven't deploy numbers (scope). Because of this, I cannot see the function logs from pull-requests deploys.

Look:
Screenshot 2020-10-10 at 17 17 33
First row - usual build with Netlify, without gh-action. We can see number of this deploy (#5), and link to logs looks like https://app.netlify.com/sites/your-project/functions/?scope=deploypreview:5.
Second row - build with gh-actions, which hasn't number of deploy, and link to logs looks like https://app.netlify.com/sites/your-project/functions/ (without scope).

Is it possible to add a scope for deploys from gh-action?
Thank you!

Support branch deploy

It seems that there is a draft PR of netlify/js-client to support branch deploy: netlify/js-client#105.
It would be great to have that functionality in actions-netlify too once the above PR is released.

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

Production deployment not working

I have the following config in my GH action workflow:

- name: Deploy to Netlify
  uses: nwtgck/[email protected]
  with:
    publish-dir: './storybook-static'
    production-deploy: true
    github-token: ${{ secrets.GITHUB_TOKEN }}
    deploy-message: "Deploy from GitHub Actions"
    enable-commit-comment: false
  env:
    NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
    NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
  timeout-minutes: 1

and the action log outputs:

image

the last two lines state:

๐ŸŽ‰ Published on https://inventage-web-components.netlify.app/ as production
๐Ÿš€ Deployed on https://621e43c1990d8e4944cef5e9--inventage-web-components.netlify.app

However, the version at the production URL (https://inventage-web-components.netlify.app/) is never updated. The preview URL (https://621e43c1990d8e4944cef5e9--inventage-web-components.netlify.app) works fine and contains the latest version.

Builds are turned off on Netlify.

Am I doing something wrong? I cannot get the production URL to serve the latest version deployed.

Docs

It is unclear what these options exactly do.

enable-pull-request-comment: true Comment on pull request (default: true)
enable-commit-comment: true Comment on GitHub commit (default: true)
enable-commit-status: true GitHub commit status (default: true)
overwrites-pull-request-comment: true Overwrites comment on pull request (default: true)

It would be helpful to go in detail to explain what happens, or link to relevant Netlify docs that probably already has some explanation.

Type 'typeof import("...@octokit/rest/index") is not a constructor function type

This problem is only related to users deploying this repo.

Develop problem

Using npm run build, you will have the following error.

[actions-netlify]$ npm run build

> [email protected] build /...
> tsc

node_modules/@actions/github/lib/github.d.ts:5:37 - error TS2507: Type 'typeof import("/.../node_modules/@octokit/rest/index")' is not a constructor function type.

5 export declare class GitHub extends Octokit {
                                      ~~~~~~~

node_modules/@actions/github/lib/github.d.ts:15:52 - error TS2694: Namespace '"/.../node_modules/@octokit/rest/index"' has no exported member 'Options'.

15     constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>);
                                                      ~~~~~~~

node_modules/@actions/github/lib/github.d.ts:16:31 - error TS2694: Namespace '"/.../node_modules/@octokit/rest/index"' has no exported member 'Options'.

16     constructor(opts: Octokit.Options);
                                 ~~~~~~~

src/main.ts:33:26 - error TS2339: Property 'issues' does not exist on type 'GitHub'.

33       await githubClient.issues.createComment({
                            ~~~~~~


Found 4 errors.

Workaround

You can directly modify ./node_modules/@actions/github/lib/github.d.ts as follows.

- import Octokit from '@octokit/rest';
+ import {Octokit} from '@octokit/rest';

Support for edge-functions

Hi!

I recently switched over all my functions to edge-functions, and now I'd like to automate their deployment. I haven't seen edge-functions mentioned anywhere here, is this possible at all with this action or are there plans to support them?

By the way, so far this action has worked flawlessly for me, really great tool, thanks for all the work!

Don't generate /dist/typescript

Problem

Currently dist/typescript is automatically generated by npm run all. I don't want to generate it because it causes type-definition's conflict problem when you run npm run build again without rm -r ./dist.

Times out with no logged errors

Except for one time, the action has timed out every time I've used it. Once I removed the timeout for the action and the entire job timed out after an hour. Every time there aren't any logged errors other than to note that it's timed out. It only worked one time. I saw that the Netlify CLI has a DEBUG environment variable that enables more logging, so I tried adding that, but still no longing. Right now I have the timeout set to 3 minutes. How do I go about fixing this?

Run nwtgck/[email protected]
  with:
    publish-dir: ./public
    production-branch: master
    github-token: ***
    deploy-message: Deploy from GitHub Actions
  env:
    NETLIFY_AUTH_TOKEN: ***
    NETLIFY_SITE_ID: ***
    DEBUG: *
##[error]The action has timed out.

Post 2 comments for two separate builds

Hi i'm using this action twice on the same PR to create two deploys, The problem is that both actions are editing the same comment and I end up with a single deploy preview url commented on the pull request.

Is there a way to have 2 comments?

Case sensitivity in branch deploys

Wanted to drop a note that I ran into an issue with branch deploys that contain uppercased letters. For example, if I set an alias as alias: ISSUE-000, the deployment shows as successful as https://issue-000--my-app.netlify.app, but opening the URL returns a 404. If I lowercase the value first, then the deployment is actually successful. May be worth putting a note in the docs for this caveat.

Action seems to erroneously state credentials not provided

I am attempting to run this action that has been in place, but appears to now be failing that credentials are not provided. The secret appears to be passed according to the logs:

Screen Shot 2020-06-23 at 2 33 35 PM

This is my job for the relevant action:

deploy:
    name: Deploy
    runs-on: ubuntu-latest
    needs: [setup, compile]
    if: ${{ needs.setup.outputs.affected-deploys != '[]' }}
    strategy:
      matrix:
        node: ['12.x']
        deploy: ${{ fromJson(needs.setup.outputs.affected-deploys) }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Set cache directory
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - name: Restore cache
        uses: actions/cache@v2
        id: yarn-cache
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      - name: Set up Node.js
        uses: actions/setup-node@v2-beta
        with:
          node-version: ${{ matrix.node }}

      - name: Install dependencies
        env:
          CACHE_HIT: ${{ steps.yarn-cache.outputs.cache-hit }}
        run: tools/scripts/yarn-ci.sh

      - name: Restore compilation
        uses: actions/download-artifact@v2
        with:
          name: dist
          path: dist/

      - run: touch dist/apps/${{ matrix.deploy.project }}/.prod.env
      - run: touch dist/apps/${{ matrix.deploy.project }}/.env

      - uses: c-py/action-dotenv-to-setenv@v1
        with:
          env-file: dist/apps/${{ matrix.deploy.project }}/.prod.env
        env:
          DOTENV_DEFAULT: dist/apps/${{ matrix.deploy.project }}/.env

      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        with:
          publish-dir: dist/apps/${{ matrix.deploy.project }}
          production-branch: master
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-commit-comment: false
          netlify-config-path: ./netlify.toml
          functions-dir: dist/functions/
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

Thanks for helping out!

Netlify preview build not using netlify.toml

Currently standard preview with comment to PR works.
I have issues regarding using custom build command for preview.
If successful urls on preview should consist of DEPLOY_URL (not the one configured in config files, I tested locally the same command and it worked).

gh action

      - name: Netlify Actions
        uses: nwtgck/[email protected]
        with:
          publish-dir: "./public"
          github-token: ${{ secrets.GITHUB_TOKEN }}
          netlify-config-path: ./netlify.toml
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN_NRCHKB_WIKI }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_NRCHKB_WIKI }}

netlify.toml

[context.deploy-preview]
command = "hugo -b $DEPLOY_URL"

[context.deploy-preview.environment]
HUGO_VERSION = "0.76"

Run
NRCHKB/NRCHKB.github.io@622caa8

No such file or directory when deploying

I have a dbt project with documentation I'd like to publish to Netlify.

By default, dbt documentation is kept in /target (e.g. ~/my_project/target). I have therefore configured my Actions YAML file as:

name: Build and Deploy to Netlify
on:
  push:
  pull_request:
jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        with:
          publish-dir: './target'
          production-branch: master
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-pull-request-comment: false
          enable-commit-comment: true
          overwrites-pull-request-comment: true
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

On pushing to master I get the error:

Run nwtgck/[email protected]
  with:
    publish-dir: ./target
    production-branch: master
    github-token: ***
  env:
    NETLIFY_AUTH_TOKEN: ***
    NETLIFY_SITE_ID: ***
Error: ENOENT: no such file or directory, lstat '/home/runner/work/my_project/my_project/target'

Can anyone point me in the right direction to resolve this?

Netlify not commenting with Display Preview on PR

Hey, I am trying to make Netlify to comment with link to preview on successufly GH action.

Link is generated but no comment is added.

Workflow here: https://github.com/NRCHKB/NRCHKB.github.io/actions/runs/1403407029/workflow

      - name: Netlify Actions
        uses: nwtgck/[email protected]
        with:
          publish-dir: './public'
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN_NRCHKB_WIKI }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_NRCHKB_WIKI }}

Action here: https://github.com/NRCHKB/NRCHKB.github.io/runs/4057360768?check_suite_focus=true

Run nwtgck/[email protected]
  with:
    publish-dir: ./public
  env:
    NETLIFY_AUTH_TOKEN: ***
    NETLIFY_SITE_ID: ***
๐Ÿš€ Deployed on https://617dd6c925c04b114eb6a1fb--naughty-raman-c58f41.netlify.app

PR here: NRCHKB/NRCHKB.github.io#103

Does not respect netlify.toml?

Could it be that this GitHub action does not respect configurations in netlify.tom? For example I have defined following redirect rule

[[redirects]]
  from = "https://me.com/*"
  to = "https://www.me.io/:splat"
  status = 301
  force = true

This redirect worked as expected before I switched from using netlify-cli in my npm scripts manually to this GitHub action ๐Ÿค”

Release notes would be great

Would it be possible to write a small release note on every release? For example the latest release does not mention anything. So I had to look into the commit history to see that we now have a new production-deploy input (which is great by the way!)

(More) deprecation warning for Node 12

I'm still seeing this:

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
Please update the following actions to use Node.js 16: nwtgck/[email protected]

After a previous issue about this was closed, someone posted another possible place this needs to be resolved, FWIW.

#837 (comment)

environment variables not working if I have build turned off

I turned the Builds off in Netlify so that this Github Action can do my builds and deploys for me. However, the environment variables I set in Netlify do not work unless I let Netlify build for me. Is there a way to pass my site environment variables in this action? Has anyone else run into this issue.

My deploy-to-prod.yml job:

name: Deploy to Netlify

on:
  push:
    branches: [master]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: hallee/[email protected]
        with:
          repo-token: ${{secrets.GITHUB_TOKEN}}
  deploy-to-production:
    needs: lint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install Dependencies
        run: yarn
      - name: Build
        run: yarn build
      - name: Deploy
        uses: nwtgck/[email protected]
        with:
          deploy-message: ${{ github.event.head_commit.message }}
          enable-commit-comment: false
          github-token: ${{ secrets.GITHUB_TOKEN }}
          production-branch: master
          production-deploy: true
          publish-dir: 'build'
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

Error: Request path contains unescaped characters

I keep on running into the same issue and the error message is not helpful. All I get is this:

Run nwtgck/[email protected]
  with:
    publish-dir: ./bundling/bundles
    production-branch: main
    netlify-config-path: ./bundling/bundles/netlify.toml
  env:
    NETLIFY_SITE_ID: ***
    NETLIFY_AUTH_TOKEN: ***
Error: Request path contains unescaped characters

How can I investigate what the problem is?

FYI there are no weird characters in the publish directoy:

Run find bundling
bundling
bundling/.gitignore
bundling/bundle-es6.ts
bundling/bundles
bundling/bundles/es6-dev.js
bundling/bundles/es6-v1.4.2.js
bundling/bundles/netlify.toml
bundling/netlify.toml

Report URL via commit status instead of via comment

Thanks very much for this Action. I'm using it successfully for Netlify deploys.

In other workflows (in the lower case sense, not GHA sense), we surface the Netlify deploy URL via a commit status, which is really nice.

https://docs.netlify.com/site-deploys/notifications/#github-commit-statuses

Screen Shot 2020-08-20 at 9 44 47 AM

(I guess that image shows using the "git commit checks" idea, but it's pretty similar to how "git commit status" approach looks and works.)

I like that this doesn't have notification consequences and doesn't clutter the PR conversation with its own comment.

Would you consider reporting the URL in that manner as an alternative to the current comment approach?

I am achieving this now by using your action and feeding its output into another action (I still have the comment turned on but I'll probably turn that off soon):

https://github.com/hadley/r-pkgs/blob/6c8e1e2ee1742384a64e707e595f0043fafc927d/.github/workflows/build-book.yaml#L79-L109

The action I'm using to add a status update to a commit is Sibz/github-status-action.

You can see all of this working together in this PR:

https://github.com/hadley/r-pkgs/pull/648/commits

Critical security issue with preview deployments

Hello,

Using this GitHub action is extremely dangerous, as you are using Personal access tokens.
Netlify does not have any granularity on permissions personal access tokens provide. This means that you are essentially deploying previews with access to the production environment.
If you are running previews on external PRs, anybody can modify the GH action workflow file and deploy it to your production website.

This cannot be solved unless Netlify provides permission selection on tokens.

Action uploads to an additional URL as well, how to disable it?

First off, thanks for your work, it's been an immense help!

I've been using this Action for quite a while & noticed search indexers crawling URLs which looks surprisingly like mine. It takes the form of <ALPHANUMERIC-STRING>--jarmos.netlify.app. Suffice to say it's hurting my indexing & SEO ratings due to duplicate entries in to the index.

After digging around a bit, I figured it's the Netlify which is deploying to more than one URL. I attached a screenshot highlighting the same. Refer to it below:

image

How do I enable to Action to only output the production URL & nothing else?

Here's the workflow file I'm using to build the site before deploying to Netlify:

name: Netlify Deploy

on:
  push:
    branches:
      - dev

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          submodules: true
          fetch-depth: 0
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "0.82.0"
      - name: Generate Static Content
        run: hugo --minify
      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        with:
          publish-dir: "./public"
          production-branch: dev
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deployed with GitHub Actions"
          netlify-config-path: ./netlify.toml
          github-deployment-environment: "Netlify Deploy"
          enable-pull-request-comment: false
          enable-commit-comment: false
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

Am I doing something wrong or is it intended behaviour? If it's the latter, is there any way I could disable it?

Clarify purpose of `github-deployment-environment`

github-deployment-environment is only used for assignment to deploying to a different environment?

I didn't seem to be able to run the workflow and provide the secrets to ENV vars that the action uses unless I specify the environment (netlify) that I assigned the secrets to. However, that seems to cause an automated deploy status by myself (to which I can optionally provide a URL). I think this cancels the action that also attempts to deploy:

Screenshot_20210506_212209

If I remove github-deployment-environment, I get a similar result, but the action defaults to pull request:

Screenshot_20210506_213355

While I like the added deploy links to the related workflow runs that this action seems to be missing, I'd prefer only the github-actions[bot] is running the deployment status update.

I'm not sure if this can be avoided, it seems to be caused by adding <job>.environment (as below in config example) - but AFAIK the action doesn't seem to be able to access the secrets from ENV with github-deployment-environment: netlify, nor can I pass those in as I had been doing prior to assigning the secrets to a deployment environment (that only seems to work if I explicitly set the environment on the job).


Relevant workflow snippet:

jobs:
  preview:
    name: 'Deploy Preview'
    runs-on: ubuntu-20.04
    # non-default environment contains the NETLIFY_* secrets below
    # Note: This setting implicitly enables another deployment status?
    environment:
      name: netlify
      url: ${{ steps.preview.outputs.deploy-url }} # required to add the "View Deployment" button (github action bot doesn't have this issue for it's own deploy status)
    steps:
      - uses: actions/checkout@v2

      - name: 'Send preview build to Netlify'
        id: preview
        uses: nwtgck/[email protected]
        timeout-minutes: 1
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          github-deployment-environment: netlify # otherwise defaults to `pull request`
          enable-pull-request-comment: false
          enable-commit-comment: false
          enable-commit-status: false

      - uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: preview
          message: |
            [Documentation preview for this PR](${{ steps.preview.outputs.deploy-url }}) is ready! :tada:

            Built with commit ${{ github.event.pull_request.head.sha }}

This issue isn't too important to resolve. I'm just trying out the environment feature, and seeing if I could get it to work smoothly with this action (not sure if I can avoid the duplicate status issue).

Perhaps instead of "Environment name of GitHub Deployments" for the github-deployment-environment description, it could be "Environment name of GitHub Deployment target (default: pull request)" or something along those lines?

Promise timed out after 1200000 milliseconds

Getting the error:

Promise timed out after 1200000 milliseconds

with v1.0.12. Here is my configuration:

    - uses: nwtgck/[email protected]
      with:
        publish-dir: exports/html5
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

Here are my logs, though they're not entirely helpful:

2020-04-17T17:23:52.3852101Z ##[group]Run nwtgck/[email protected]
2020-04-17T17:23:52.3852244Z with:
2020-04-17T17:23:52.3852363Z   publish-dir: exports/html5
2020-04-17T17:23:52.3852472Z env:
2020-04-17T17:23:52.3853290Z   NETLIFY_AUTH_TOKEN: ***
2020-04-17T17:23:52.3853418Z   NETLIFY_SITE_ID: ***
2020-04-17T17:23:52.3853529Z ##[endgroup]
2020-04-17T17:43:52.9631918Z ##[error]Promise timed out after 1200000 milliseconds

Thanks.

output deploy id

Would it be possible to add an output containing the deploy id? It would be helpful to use the id later in the workflow. My use case is promoting to production only after the rest of the CI pipeline is complete.

Thanks!

[bug]: Deployment description accidentally uses deployment environment

I commented on the relevant PR yesterday, but in case it is missed I am raising an issue about it.

There was a typo when adding this feature, probably caused from copy/paste or autocomplete:

https://github.com/scopsy/actions-netlify/blob/e4c631a02a86a78d7840cc3398f6d67260e84589/src/main.ts#L190


I'm not sure where in the UI the deployment description is visible at, but I do know how to view it via the Github API:

When using this feature, you can query deployments via CLI like so (example based on official github api docs):

curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/nwtgck/actions-netlify/deployments | less

Then look at the JSON data, something like:

    "task": "deploy",
    "original_environment": "pull request",
    "environment": "pull request",
    "description": null,

null would incorrectly be the pull request environment if you enabled the description feature, instead of whatever value you assign the description.

Question: promote a deploy as the main deploy?

Awesome work on actions-netlify! I'm really loving this and I'm very thankful that this exists.

Is it possible to make a deployment the main one that appears in my-site.netlify.app? When I try to set this up, the URL appears as <alias>--my-site.netlify.app.

Deprecation warning for Node 12

Hello, and thanks a lot for this awesome action!

I have started encountering this warning in my CI lately:

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: nwtgck/actions-netlify

Is the update to Node 16 on the roadmap?

Upload crashes when using TS files in the 'functions' folder

Hi there,

I just found out that the plugin crashes and gives a strange error message when using TypeScript files within the functions directory.
To test this I have created an empty index.ts file within a functions folder.

I also set functions-dir: './functions' in the config.

When the Github Action is triggered I get the following error:

Schermafbeelding 2022-05-25 om 16 27 09

This problem does not occur when using only JS files.

Bad credentials

Hi there!
The preview deploy has done and works, but I got a error with credentials, I thought fails-without-credentials: false flag will help me, but..

Screenshot 2021-07-08 at 10 43 16

config:

on:
  pull_request:
    branches: 
      - main
    tags-ignore:
      - 'v*.*'

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      ...build script

      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        if: startsWith(github.head_ref, 'dependabot/*') == false
        with:
          publish-dir: 'storybook-static'
          production-branch: main
          github-token: Qvant-lab:${{ secrets.GITHUB_TOKEN }}
          enable-commit-comment: true
          overwrites-pull-request-comment: true
          fails-without-credentials: false
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

on: push works fine, trouble with pull_request
Repo:
https://github.com/Qvant-lab/qui-max

Does this action allow for builds?

I've got the following github actions setup:

name: Build and Deploy to Netlify
on:
  push:
  pull_request:
    types: [opened, synchronize]
jobs:
  build:
    runs-on: ubuntu-18.04
    defaults:
      run:
        working-directory: frontend
    steps:
      - uses: actions/checkout@v2
      - run: npm --version && node --version
      - run: npm i
      - run: npm run build
      - run: npm install -D netlify-cli
      - run: npx netlify-cli status
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      - run: npx netlify-cli build
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      - name: Deploy to Netlify
        uses: nwtgck/[email protected]
        with:
          publish-dir: './out_publish'
          functions-dir: './out_functions'
          production-branch: master
          # github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-pull-request-comment: false
          enable-commit-comment: true
          overwrites-pull-request-comment: true
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

It it possible to instead somehow use the action to do the build... this setup that I have doesn't work btw due to some weird stuff going on with the netlify-cli which is really annoying!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.