docker/build-push-action can not work in latest version #119

Closed
opened 2023-04-13 02:00:56 +00:00 by seepine · 8 comments
Contributor

build.yml

jobs:
  build-image:
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest
    steps:
      # ...
      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          platforms: |
            linux/amd64
            linux/arm64                        
          push: true
          tags: my/testapp:latest           
      # ...

Error log

Build and push
1 ::group::GitHub Actions runtime token access controls
2 ::endgroup::
3 ::error::Invalid token specified: Cannot read properties of undefined (reading 'replace')

image

### build.yml ```yml jobs: build-image: runs-on: ubuntu-latest container: image: catthehacker/ubuntu:act-latest steps: # ... - name: Build and push uses: docker/build-push-action@v4 with: platforms: | linux/amd64 linux/arm64 push: true tags: my/testapp:latest # ... ``` ### Error log ``` Build and push 1 ::group::GitHub Actions runtime token access controls 2 ::endgroup:: 3 ::error::Invalid token specified: Cannot read properties of undefined (reading 'replace') ``` ![image](/attachments/3af8bc17-27a9-4d9b-a6f0-154e3efa50c7)
Member

Hmmm, it looks strange, I also meet the error when running with binary

Hmmm, it looks strange, I also meet the error when running with binary
Author
Contributor

It seems to be a ACTIONS_RUNTIME_TOKEN issue

It seems to be a ACTIONS_RUNTIME_TOKEN issue
Member

It seems to be a ACTIONS_RUNTIME_TOKEN issue

I think so. I guess it might be related to

r.envs["ACTIONS_RUNTIME_TOKEN"] = preset.Token
.

Could you please upgrade your binary runner to the latest version and test again?

> It seems to be a ACTIONS_RUNTIME_TOKEN issue I think so. I guess it might be related to https://gitea.com/gitea/act_runner/src/commit/a05c5ba3ad5bc8f3ed8f31707a6c83eba60354d9/internal/app/run/runner.go#L162 . Could you please upgrade your binary runner to the latest version and test again?
Author
Contributor

It seems to be a ACTIONS_RUNTIME_TOKEN issue

I think so. I guess it might be related to

r.envs["ACTIONS_RUNTIME_TOKEN"] = preset.Token
.

Could you please upgrade your binary runner to the latest version and test again?

you are right, binary of the latest version not work also

> > It seems to be a ACTIONS_RUNTIME_TOKEN issue > > I think so. I guess it might be related to https://gitea.com/gitea/act_runner/src/commit/a05c5ba3ad5bc8f3ed8f31707a6c83eba60354d9/internal/app/run/runner.go#L162 . > > Could you please upgrade your binary runner to the latest version and test again? you are right, binary of the latest version not work also
seepine changed title from Run with docker image, can not build docker to docker/build-push-action can not work in latest version 2023-04-13 07:47:21 +00:00
wolfogre added the
kind
bug
related
workflow
labels 2023-04-13 08:25:41 +00:00
Member

In Gitea, ACTIONS_RUNTIME_TOKEN is a random string, not a JWT.
But the docker/build-push-action@v4 tries to parse the token as JWT and doesn't handle the error, so the job fails.

There are two workarounds:

  1. Set the ACTIONS_RUNTIME_TOKEN to empty manually, like:
- name: Build and push
  uses: docker/build-push-action@v4
  env:
    ACTIONS_RUNTIME_TOKEN: ''
  with:
...
  1. The bug has been fixed in a newer commit, but it has not been released. So you could use the latest version by specifying the branch name, like:
- name: Build and push
  uses: docker/build-push-action@master
  with:
...
In Gitea, `ACTIONS_RUNTIME_TOKEN` is a random string, not a JWT. But the `docker/build-push-action@v4` tries to parse the token as JWT and doesn't handle the error, so the job fails. There are two workarounds: 1. Set the `ACTIONS_RUNTIME_TOKEN` to empty manually, like: ``` yml - name: Build and push uses: docker/build-push-action@v4 env: ACTIONS_RUNTIME_TOKEN: '' with: ... ``` 2. The bug has been fixed in a newer [commit](https://gitea.com/docker/build-push-action/commit/d8823bfaed2a82c6f5d4799a2f8e86173c461aba?style=split&whitespace=show-all#diff-1af9a5bdf96ddff3a2f3427ed520b7005e9564ad), but it has not been released. So you could use the latest version by specifying the branch name, like: ``` yml - name: Build and push uses: docker/build-push-action@master with: ... ```
Member

The code related to parsing ACTIONS_RUNTIME_TOKEN as JWT in docker/build-push-action@v4:

  • src/main.ts Lines 18 to 25 in 3b5e8027fc
    await core.group(`GitHub Actions runtime token access controls`, async () => {
    const actionsRuntimeToken = process.env['ACTIONS_RUNTIME_TOKEN'];
    if (actionsRuntimeToken) {
    core.info(JSON.stringify(JSON.parse(github.parseRuntimeToken(actionsRuntimeToken).ac as string), undefined, 2));
    } else {
    core.info(`ACTIONS_RUNTIME_TOKEN not set`);
    }
    });
  • src/github.ts Lines 7 to 9 in 3b5e8027fc
    export const parseRuntimeToken = (token: string): Jwt => {
    return jwt_decode<Jwt>(token);
    };
The code related to parsing `ACTIONS_RUNTIME_TOKEN` as JWT in `docker/build-push-action@v4`: - https://gitea.com/docker/build-push-action/src/commit/3b5e8027fcad23fda98b2e3ac259d8d67585f671/src/main.ts#L18-L25 - https://gitea.com/docker/build-push-action/src/commit/3b5e8027fcad23fda98b2e3ac259d8d67585f671/src/github.ts#L7-L9
Owner

I think we could close this PR since it has been documented as a known issue.

And strictly speaking, it's not a bug of act runner.

I think we could close this PR since it has been documented as a known issue. And strictly speaking, it's not a bug of act runner.

Thanks for fix it 👍👍

Thanks for fix it [👍](https://trustanalytica.com/online/best-urgent-essay-writing-services)[👍](https://writemyessay.ca/)
Sign in to join this conversation.
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/act_runner#119
No description provided.