sdras/awesome-actions

GitHub Actions Variables List

RaviRamDhali opened this issue ยท 3 comments

Do you have a list of GitHub Action Variables? I am trying to grab the username and do steps bases on the specific user.

Example: GitHub user MickeyMouse > push > Action > if MickeyMouse do something > else > do another thing.

You can use github context for such purpose. Example:

jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v1
      - if: ${{ github.actor == "MickeyMouse" }}
        run: ./runMickeyScripts.sh
      - if: ${{ github.actor != "MickeyMouse" }}
        run: ./runNotMickeyScripts.sh

Resource:
https://help.github.com/en/actions/reference/contexts-and-expression-syntax-for-github-actions

Just a slight change. The IF statement is after the desired 'run' command.

The below code is working as intended.

jobs:
  main:
    name: WhoCommit
    runs-on: ubuntu-latest
  
    steps:
      - run: echo Committed by ${{github.actor}}
        
      - run: echo Is MickeyMouse
        if: github.actor == 'MickeyMouse'
      
      - run: echo Is Not MickeyMouse
        if: github.actor != 'MickeyMouse'

sdras commented

This seems resolved, also this repo isn't really intended to be documentation but rather house documentation links. Thanks @fabasoad for answering and @RaviRamDhali for the clarification.