Allow `if` Blocks in steps
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file, test, or entry point is named. Start by locating the toolkit’s workflow-step parsing and validation entry points, then determine how nested conditional blocks would be represented and executed. Done means the proposed syntax is accepted and the condition applies to every nested step, with tests covering the Linux, macOS, and Windows examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions
- Domain
- ci-cd
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100