actions / runner-container-hooks

Runner Container Hooks for GitHub Actions
MIT License
76 stars 46 forks source link

k8s hook: equal signs (=) in environment vars are escaped in job pods #61

Closed syslxg closed 1 year ago

syslxg commented 1 year ago

while using k8s container mode with ARC, I found 'google-github-actions/auth@v1' action stopped working and the problem was '=' in base64 strings were escaped ('\=') and that broke the JSON parsing.

the following workflow can show this problem.

name: K8S runner env issue
env:
  foo: '{"user": "YWJjCg=="}'
on:
  workflow_dispatch:
jobs:
  envissue:
    runs-on: k8s
    container:
      image: ubuntu
    steps:
    - run: |
        apt-get update
        apt-get install -y jq
        echo "foo: $foo"        
        echo "$foo" | jq -r .user

This workflow will fail on k8s runners (with k8s hook) Actual output is :

foo: {"user": "YWJjCg\=\="}
parse error: Invalid escape at line 1, column 21

expected output is:

foo: {"user": "YWJjCg=="}
YWJjCg==
syslxg commented 1 year ago

I guess the problem is caused by this line:

https://github.com/actions/runner-container-hooks/blob/4307828719ac24f4ae307f9eba1387a65b34becf/packages/k8s/src/k8s/utils.ts#L117

nikola-jokic commented 1 year ago

Hey @syslxg,

Thank you for reporting this clearly and providing likely cause! I'll try to push a fix as soon as I can :relaxed: