Git Product home page Git Product logo

Comments (4)

creyD avatar creyD commented on June 14, 2024

This isn't really possible because -as for the GITHUB_TOKEN-, my repository and therefore the Action can't access the issuing (your) repository. Even if you provide the event name, my action doesn't know where to push to. If you just only want to merge to the origin branch, then this should do the job -the on parameter is documented here:

on: [push, pull_request]
- name: Prettier Action on master
  if: github.event_name == 'push' && github.ref == 'refs/heads/master'
  uses: creyD/[email protected]
  with:
    prettier_options: "--write {**/*,*}.{js,html,json,md,yml,css,scss}"
    branch: ${{ github.ref }}
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The branch SHOULD be filled with master automatically if it's the on push event.

from prettier_action.

adriaandotcom avatar adriaandotcom commented on June 14, 2024

I'm already using the on parameter like this:

on:
  pull_request:
    types: [opened, synchronize]
  push:
    branches:
      - master

Which works great.

I think I'm not clear on what I would love to have. I would love that the GitHub Action would work without specifying the branch. Or where it would work for both a PR and for a normal push.

Maybe this works?

on:
  pull_request:
    types: [opened, synchronize]
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - name: Prettier Action on master
        uses: creyD/[email protected]
        with:
          prettier_options: "--write {**/*,*}.{js,html,json,md,yml,css,scss}"
          branch: ${{ github.head_ref || github.ref }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Note the branch name: ${{ github.head_ref || github.ref }}.

from prettier_action.

creyD avatar creyD commented on June 14, 2024

I think you could do this with an if statement in your code. ${{ github.head_ref || github.ref }} won't work, but if you implement this functionality with a if else statement, it should work!

from prettier_action.

adriaandotcom avatar adriaandotcom commented on June 14, 2024

Thanks, will try!

from prettier_action.

Related Issues (20)

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.