nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
54.62k stars 1.36k forks source link

Running ACT hangs when downloading the ac-latest docker image. #1803

Open codeninja opened 1 year ago

codeninja commented 1 year ago

Bug report info

act version:            0.2.45
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
Config files:           
        /home/codeninja/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.18.10
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -compiler:            gc
                -ldflags:             -s -w -X main.version=0.2.45 -X main.commit=f1df2ca5d6b315935cf9bb0d2a989175adf4e894 -X main.date=2023-05-01T02:18:49Z -X main.builtBy=goreleaser
                CGO_ENABLED:          0
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
                vcs:                  git
                vcs.revision:         f1df2ca5d6b315935cf9bb0d2a989175adf4e894
                vcs.time:             2023-05-01T02:18:34Z
                vcs.modified:         false
Docker Engine:
        Engine version:        20.10.24
        Engine runtime:        runc
        Cgroup version:        1
        Cgroup driver:         cgroupfs
        Storage driver:        overlay2
        Registry URI:          https://index.docker.io/v1/
        OS:                    Docker Desktop
        OS type:               linux
        OS version:            
        OS arch:               x86_64
        OS kernel:             5.15.90.1-microsoft-standard-WSL2
        OS CPU:                16
        OS memory:             64280 MB
        Security options:
                name=seccomp,profile=default

Command used with act

./bin/act -j determine-affected-apps -W .github/workflows/deploy-to-staging-with-matrix.yml -s TOKEN_GIT='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'

Describe issue

Act command fails due to broken build in the docker image. DOcker hub refuses to pull.

[Deploy to Staging with Matrix/determine-affected-apps] 🚀  Start image=catthehacker/ubuntu:act-latest
[Deploy to Staging with Matrix/determine-affected-apps]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
^C[Deploy to Staging with Matrix/determine-affected-apps] failed to remove container: Delete "http://%2Fvar%2Frun%2Fdocker.sock/v1.41/containers/c6f1b4dde24a4317f8ce42157e62e528811428e51a88789f0674878ce2c09594?force=1&v=1": context canceled
Error: context canceled```

### Link to GitHub repository

_No response_

### Workflow content

```yml
name: Deploy to Staging with Matrix

env:
  APPLICATION_NAME: content-at-scale
  CURRENT_ENV: stage
  INFRA_REPO_BRANCH: main
  HELM_CHART_PATH: kubernetes/helm/applications
  GAR_LOCATION: us-central1
  PROJECT_ID: tr-infra-ops
  REPOSITORY: tr-docker-images
  GITHUB_AUTH_TOKEN: ${{ secrets.TOKEN_GIT }}

on:
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:

  determine-affected-apps:
    runs-on: ubuntu-latest
    outputs:
      buildMatrix: ${{ steps.set-matrix.outputs.buildMatrix }}
      deployMatrix: ${{ steps.set-matrix.outputs.deployMatrix }}
    steps:

      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Make envfile
        uses: SpicyPizza/create-envfile@v1.3

      - name: Install yarn
        run: npm install -g yarn 

      - name: Setup Node and Cache Dependencies
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
          cache: 'yarn'
          token: ${{ env.GITHUB_AUTH_TOKEN }}
      - run: yarn install --frozen-lockfile

      - name: Determine affected apps
        id: set-matrix
        run: |
          echo "::set-output name=buildMatrix::$(yarn nx print-affected --target=build-docker --base=origin/main --head=HEAD --select=tasks.target.project --json)"
          echo "::set-output name=deployMatrix::$(yarn nx print-affected --target=deploy-name --base=origin/main --head=HEAD --select=tasks.target.project --json)"

  build-image:
    needs: [determine-affected-apps]
    runs-on: ubuntu-latest
    environment: staging
    strategy:
      fail-fast: false
      matrix:
        app: ${{needs.determine-affected-apps.outputs.buildMatrix}}
    permissions:  
      contents: read
      actions: read
      id-token: write
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Make envfile
        uses: SpicyPizza/create-envfile@v1.3

      - name: Authenticate to Google Cloud
        if: ${{ !env.ACT }}
        id: auth
        uses: google-github-actions/auth@v0
        with:
          workload_identity_provider: projects/637937044048/locations/global/workloadIdentityPools/github-actions/providers/github-oidc
          service_account: github-actions@tr-infra-ops.iam.gserviceaccount.com

      - name: Set up Cloud SDK
        if: ${{ !env.ACT }}
        uses: google-github-actions/setup-gcloud@v0

      - name: Docker configuration
        if: ${{ !env.ACT }}
        run: gcloud --quiet auth configure-docker $GAR_LOCATION-docker.pkg.dev

      - name: Install yarn
        run: npm install -g yarn 

      - name: Setup Node and Cache Dependencies
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
          cache: 'yarn'
          token: ${{ env.GITHUB_AUTH_TOKEN }}

      - name: Build Image
        run: |
          yarn nx run data-mongodb:compile
          yarn nx run data-postgres:compile
          yarn nx run ${{ matrix.app }}:build-docker
        env:
          GAR_LOCATION: ${{ env.GAR_LOCATION }}
          GAR_PROJECT_ID: ${{ env.PROJECT_ID }}
          GAR_REPOSITORY: ${{ env.REPOSITORY }}
          NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

      - name: Tag and push image to GAR
        if: ${{ !env.ACT }}
        run: |
          docker tag $GAR_LOCATION-docker.pkg.dev/$GAR_PROJECT_ID/$GAR_REPOSITORY/${{ matrix.app }}:$GITHUB_SHA \
            $GAR_LOCATION-docker.pkg.dev/$GAR_PROJECT_ID/$GAR_REPOSITORY/${{ matrix.app }}:$CURRENT_ENV
          docker push -a $GAR_LOCATION-docker.pkg.dev/$GAR_PROJECT_ID/$GAR_REPOSITORY/${{ matrix.app }}

  set-tag:
    needs: [determine-affected-apps, build-image]
    runs-on: ubuntu-latest
    environment: staging
    strategy:
      fail-fast: false
      matrix:
        app: ${{needs.determine-affected-apps.outputs.deployMatrix}}
    permissions:  
      contents: read
      actions: read
      id-token: write
    steps:
      - name: Export commit author as envs
        id: set-commit-envs
        run: |
          echo "commit_author_name=$(git log --format='%an <%ae>' -n 1 HEAD | cut -d '<' -f 2 | cut -d '@' -f 1)" >> $GITHUB_ENV
          echo "commit_author_email=$(git log --format='%an <%ae>' -n 1 HEAD | cut -d '<' -f 2 | cut -d '>' -f 1)" >> $GITHUB_ENV
          echo "commit_author=$(git log --format='%an <%ae>' -n 1 HEAD)" >> $GITHUB_ENV

      - name: Set new tags
        run: |
          sed -ri "s/tag: [a-z,0-9]{40}/tag: $GITHUB_SHA/" $HELM_CHART_PATH/$APPLICATION_NAME/$CURRENT_ENV.values.yaml

      - name: Commit and push changes
        env:
          COMMIT_AUTHOR_NAME: ${{ steps.set-commit-envs.outputs.COMMIT_AUTHOR_NAME }}
          COMMIT_AUTHOR_EMAIL: ${{ steps.set-commit-envs.outputs.COMMIT_AUTHOR_EMAIL }}
          COMMIT_AUTHOR: ${{ steps.set-commit-envs.outputs.COMMIT_AUTHOR }}
        run: |
          git config user.name $COMMIT_AUTHOR_NAME
          git config user.email $COMMIT_AUTHOR_EMAIL
          git add $HELM_CHART_PATH/$APPLICATION_NAME/$CURRENT_ENV.values.yaml
          git commit -m "Deploying image $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$APPLICATION_NAME:$GITHUB_SHA Author: $COMMIT_AUTHOR"
          git push origin $INFRA_REPO_BRANCH

Relevant log output

) codeninja[~/trustradius/tr-nx](codeninja-patch-1)$ ./bin/act -j determine-affected-apps -W .github/workflows/deploy-to-staging-with-matrix.yml -s TOKEN_GIT='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'
[Deploy to Staging with Matrix/determine-affected-apps] 🚀  Start image=catthehacker/ubuntu:act-latest
[Deploy to Staging with Matrix/determine-affected-apps]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true

*** HANGS here forever.

Additional information

No response

ennioVisco commented 1 year ago

Any updates on this? Act looks kinda cool but it seems it is not working :/

ennioVisco commented 1 year ago

Thanks to https://github.com/nektos/act/discussions/1165#discussioncomment-2772110 , we have a workaround:

docker login --username your_username_here
docker pull node:16-buster-slim

Then act should work :)

NavidBecause commented 9 months ago

any updates on this?

I tried this but sadly it didn't work for me

Omarabdul3ziz commented 7 months ago

what i noticed is it is not hanging it is just taking some time to download the image, the image size is about image=catthehacker/ubuntu:act-latest is about 1.2GB

i noticed this when i tried to pull the image will docker cli

docker pull image=catthehacker/ubuntu:act-latest

and after it finished, act worked fine

RS185734 commented 6 months ago

@codeninja How does the workload_identity_provider work in act locally?

i got below

[GCP Deploy Infrastructure/infra-deploy]   
❗  ::error::google-github-actions/auth failed with: retry function failed after 4 attempts: 
gitHub Actions did not inject $ACTIONS_ID_TOKEN_REQUEST_TOKEN or $ACTIONS_ID_TOKEN_REQUEST_URL into this job. 
This most likely means the GitHub Actions workflow permissions are incorrect, or this job is being run from a fork. For more information,
please see https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
kirtimanmishrazipstack commented 3 months ago

I am still facing the same issues.

If I run act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -W .github/workflows/ It is stuck at docker pull image=nektos/act-environments-ubuntu:18.04 platform= username= forcePull=false

If I run act -W .github/workflows/ It is stuck at docker pull image=catthehacker/ubuntu:full-latest platform= username= forcePull=true

varun-hopstack commented 2 weeks ago

Any updates or fixes to this?

ChristopherHX commented 2 weeks ago

Using act -v has a bit too much docker pull progress logging and that is older than this issue.

e.g. the current issue template suggests an act cli command with -v as well, while this issue doesn't mentioned verbose mode anywhere.

Not on my backlog, I'm labeling as confirmed not planned

varun-hopstack commented 2 weeks ago

@ChristopherHX - yeah, noticed the same. Any workaround to this?