Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow if Blocks in steps #677

Open
fchorney opened this issue Dec 17, 2020 · 0 comments
Open

Allow if Blocks in steps #677

fchorney opened this issue Dec 17, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@fchorney
Copy link

Describe the enhancement
I'm finding that it is quite annoying to have to define an if condition for every single item in the steps section of a test matrix. It would be great if you could define a block per se

Code Snippet
For instance, let's say I have a setup like so

      # Linux
      - name: Wait / Sleep
        uses: jakejarvis/wait-action@v0.1.0
        if: ${{ runner.os == 'Linux' }}
        with:
          time: '1m'
      - name: Collect Docker Logs
        uses: jwalton/gh-docker-logs@v1.0.0
        if: ${{ runner.os == 'Linux' }}
      - name: Check running containers
        run: docker ps -a
        if: ${{ runner.os == 'Linux' }}
      - name: Set PGHOST on Linux
        run: echo "PGHOST=localhost" >> $GITHUB_ENV
        if: ${{ runner.os == 'Linux' }}
      # MacOS
      - name: Set PGUSER on macOS
        run: |
          echo "PGUSER=$USER" >> $GITHUB_ENV
          echo "LIBPQJL_DATABASE_USER=$USER" >> $GITHUB_ENV
        if: ${{ runner.os == 'macOS' }}
      - name: Start Homebrew PostgreSQL service
        run: pg_ctl -D /usr/local/var/postgres start
        if: ${{ runner.os == 'macOS' }}
      # Windows
      - name: Add PostgreSQL to Path
        run: |
          echo $env:PGBIN
          echo $env:PGBIN | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
        if: ${{ runner.os == 'Windows' }}
      - name: Start Windows PostgreSQL service
        run: |
          pg_ctl -D $env:PGDATA start
          pg_ctl -D $env:PGDATA status
        if: ${{ runner.os == 'Windows' }}

It would be awesome if it could be formatted like so:

      # Linux
      - if: ${{ runner.os == 'Linux' }}
        - name: Wait / Sleep
          uses: jakejarvis/wait-action@v0.1.0
          with:
            time: '1m'
        - name: Collect Docker Logs
          uses: jwalton/gh-docker-logs@v1.0.0
        - name: Check running containers
          run: docker ps -a
        - name: Set PGHOST on Linux
          run: echo "PGHOST=localhost" >> $GITHUB_ENV
      # MacOS
      - if: ${{ runner.os == 'macOS' }}
        - name: Set PGUSER on macOS
          run: |
            echo "PGUSER=$USER" >> $GITHUB_ENV
            echo "LIBPQJL_DATABASE_USER=$USER" >> $GITHUB_ENV
        - name: Start Homebrew PostgreSQL service
          run: pg_ctl -D /usr/local/var/postgres start
      # Windows
      - if: ${{ runner.os == 'Windows' }}
        - name: Add PostgreSQL to Path
          run: |
            echo $env:PGBIN
            echo $env:PGBIN | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
        - name: Start Windows PostgreSQL service
          run: |
            pg_ctl -D $env:PGDATA start
            pg_ctl -D $env:PGDATA status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant