enriikke / gatsby-gh-pages-action

GitHub Action to build and deploy your Gatsby site to GitHub Pages ❤️🎩
MIT License
295 stars 62 forks source link

Added `skip-publish` argument for validating pull requests #16

Closed kenjdavidson closed 4 years ago

kenjdavidson commented 4 years ago

Not sure if you're interested or not, but I added a skip-publish: [false | true] argument that allows validation of build (without publishing) of pull requests.

When configured with:

name: validate-pull-request

on:
  pull_request:
    branches: 
      - gatsby

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - uses: kenjdavidson/gatsby-gh-pages-action@feature/build-only-config
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}
          skip-publish: true

the result will be:

info Done building in 37.636706557 sec
Finished building your site.
Builing completed successfully - skipping publish

Regardless, thanks for a great action.

enriikke commented 4 years ago

This is a fantastic idea @kenjdavidson! Thank you for the PR and for updating the docs! 😃

hobofan commented 4 years ago

This seems to be broken. Even when you explicitly specify skip-publish: false (like in this build for this commit), it won't publish.

The only way I got it to deploy again was to revert to the previous commit of this repo.

kenjdavidson commented 4 years ago

It looks like inputs are always processed/converted to strings, even when the following:

 skipPublish: false

It's being processed as:

let skipPublish = core.getInput('skipPublish');
// skipPublish == 'false' 

hence the never actually working. This was 100% my fault for never going back and negative testing. I just went back and looked at the docs, the only place that mentions string is

inputs.<input_id>.default
Optional A string representing the default value. The default value is used when an input parameter isn't specified in a workflow file.

which I guess should imply that it's a string even when it's add in the config.

enriikke commented 4 years ago

Thanks for reporting this @hobofan! And thanks @kenjdavidson for a quick fix! 😃

I'll spend some time adding tests so we can capture things like this earlier. 👍