yq/usage/github-action.md
2022-07-28 11:33:14 +10:00

1.8 KiB

GitHub Action

Guide

You can use yq in your GitHub action, for instance:

  - uses: actions/checkout@v2
  - name: Get SDK Version from config
    id: lookupSdkVersion
    uses: mikefarah/yq@master
    with:
      cmd: yq '.renutil.version' 'config.yml'
  - name: Restore Cache
    id: restore-cache
    uses: actions/cache@v2
    with:
      path: ../renpy
      key:  ${{ runner.os }}-sdk-${{ steps.lookupSdkVersion.outputs.result }}
      restore-keys: |
        ${{ runner.os }}-sdk        
  # ... more

The yq action sets a result variable in its output, making it available to subsequent steps. In this case it's available as steps.lookupSdkVersion.outputs.result.

Details of how the GitHub action itself is configured can be found here

If you enable step debug logging, you can see additional information about the exact command sent as well as the response returned within the GitHub Action logs.

Thanks @devorbitus!

Troubleshooting

Write in-place file permission errors

The default user in github action dockerfiles (at the time of writing) seems to be 1001. This is what the yq github action is configured to run with (see the docker file here)

There's a working example defined here and you can see the Github action results here

If you need to set the action to another user, follow the advice here.