Repository: nektos/act (language: go)

Issue:
While attempting to pull image, Act throws: Error: invalid reference format
<!--
    - Make sure you are able to reproduce it on the [latest version](https://github.com/nektos/act/releases)
    - Search the existing issues.
    - Refer to [README](https://github.com/nektos/act/blob/master/README.md).
-->

## System information

    - Operating System: macOS
    - Architecture: arm64 (64-bit) M1 Apple
    - Apple M1: yes
    - Docker version: 20.10.12
    - Docker image used in `act`: < can be omitted if it's included in log >
    - `act` version: act version HEAD-e23223a

## Expected behaviour
Docker image successfully pulls.

## Actual behaviour

    ❯ act
    [Build and Test/build-test   ] 🚀  Start image=ghcr.io/catthehacker/ubuntu:act-20.04
    [Build and Test/build-test   ]   🐳  docker pull image=ghcr.io/catthehacker/ubuntu:act-20.04  platform=linux/amd64     username= forcePull=false
    ERRO[0000] invalid reference format
     Error: invalid reference format

## Configuration
    ❯ cat ~/.actrc
    -P sdp-im887-imali=ghcr.io/catthehacker/ubuntu:act-20.04
    --container-architecture linux/amd64

Without the -P above, I get the following warning message:

    ❯ act -l
    WARN  ⚠ You are using Apple M1 chip and you have not specified container architecture, you might encounter issues while running act. 
    If so, try running it with '--container-architecture linux/amd64'.

## Workflow and/or repository

```
name: Build and Test
on: push
jobs:
  build-test:
    runs-on: sdp-im887-imali
    steps:
      - name: BUILD AND TEST
        run: echo "built and tested successfully"
```

</details>

## Steps to reproduce

Run act command.

## `act` output

<details>
  <summary>Log</summary>

```none
❯ act -v
DEBU[0000] Loading environment from /Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.env
DEBU[0000] Loading secrets from /Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.secrets
DEBU[0000] Loading workflows from '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows'
DEBU[0000] Loading workflows recursively
DEBU[0000] Found workflow 'ci.yaml' in '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/ci.yaml'
DEBU[0000] Found workflow 'cicd.yaml' in '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/cicd.yaml'
DEBU[0000] Reading workflow '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/ci.yaml'
DEBU[0000] Correcting if statements '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/ci.yaml'
DEBU[0000] Reading workflow '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/cicd.yaml'
DEBU[0000] Correcting if statements '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.github/workflows/cicd.yaml'
DEBU[0000] Planning event: push
DEBU[0000] Loading slug from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Loading revision from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
DEBU[0000] HEAD points to '5e9df33e966f8aa468cafea62ad436e71fe861bc'
DEBU[0000] using github ref: refs/heads/master
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
DEBU[0000] expression 'success()' evaluated to 'true'
[Build and Test/build-test] 🚀  Start image=ghcr.io/catthehacker/ubuntu:act-20.04
DEBU[0000] Loading slug from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Loading revision from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
DEBU[0000] HEAD points to '5e9df33e966f8aa468cafea62ad436e71fe861bc'
DEBU[0000] using github ref: refs/heads/master
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
[Build and Test/build-test]   🐳  docker pull image=ghcr.io/catthehacker/ubuntu:act-20.04  platform=linux/amd64 username= forcePull=false
[Build and Test/build-test]   🐳  docker pull ghcr.io/catthehacker/ubuntu:act-20.04
DEBU[0000] Image exists? false
ERRO[0000] invalid reference format
[Build and Test/build-test] pulling image '' (linux/amd64)
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] invalid reference format
DEBU[0000] Loading slug from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Loading revision from git directory '/Users/jxc07rc/src/imali/im887-imali-ecs-cluster/.git'
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
DEBU[0000] HEAD points to '5e9df33e966f8aa468cafea62ad436e71fe861bc'
DEBU[0000] using github ref: refs/heads/master
DEBU[0000] Found revision: 5e9df33e966f8aa468cafea62ad436e71fe861bc
DEBU[0000] invalid reference format
Error: invalid reference format
```

</details>



Discussion / hints:
The reason this occurs is because of an extra space added to the end of the -P line in ~/actrc file. If you remove the space after the image name, everything works. so this is a parsing bug. spaces should be ignored. 

Fix patch:
diff --git a/cmd/root.go b/cmd/root.go
index 69f0ed7b824..655510aaaa7 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -124,7 +124,7 @@ func readArgsFile(file string) []string {
 	}()
 	scanner := bufio.NewScanner(f)
 	for scanner.Scan() {
-		arg := scanner.Text()
+		arg := strings.TrimSpace(scanner.Text())
 		if strings.HasPrefix(arg, "-") {
 			args = append(args, regexp.MustCompile(`\s`).Split(arg, 2)...)
 		}


Test patch: