question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Action doesn't perform git checkout

See original GitHub issue

Behaviour

Expected behaviour

According to README:

By default, this action uses the Git context so you don’t need to use the actions/checkout action to checkout the repository because this will be done directly by buildkit.

Actual behaviour

Checkout doesn’t happen.

Configuration

This

      - name: Build and push container
        uses: docker/build-push-action@v2
        with:
          context: ./app
          push: true
          tags: ${{ env.ECR_REGISTRY }}/proxyco/madmax-api:stable

fails with error:

/usr/local/bin/docker buildx build --tag ***.dkr.ecr.us-west-2.amazonaws.com/proxyco/madmax-api:stable --iidfile /tmp/docker-build-push-s6cfCu/iidfile --metadata-file /tmp/docker-build-push-s6cfCu/metadata-file --push ./app
error: unable to prepare context: path "./app" not found
Error: buildx failed with: error: unable to prepare context: path "./app" not found

I have to explicitly do a checkout first, for the build to be successful.

      - uses: actions/checkout@v2

      - name: Build and push container
        uses: docker/build-push-action@v2
        with:
          context: ./app
          push: true
          tags: ${{ env.ECR_REGISTRY }}/proxyco/madmax-api:stable

It’s a private repo.

This is run on a self-hosted runner using ubuntu-latest.

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
actualbencommented, Dec 28, 2021

👍 I was working on a PR myself but you were much quicker! I’ve submitted mine as a friendly alternative.

3reactions
actualbencommented, Dec 27, 2021

You’re specifying a path context string (./app) which overrides the described automagic.

It looks like you want to specify a subdir on your build. You can still have most of the automagic by specifying the context as a full git repo URL in the way described by the docker build docs’ description of Git Repo URLs. You’d use one with a trailing :app. Something like:

context: https://github.com/proxyco/madmax-api.git#${{ env.GITHUB_REF }}:app

To make it a bit more reusable you can do something like:


jobs:
  buildo:
    runs-on: ubuntu-latest
    env:
      CONTEXT_SUBDIR: app
    steps:
      - name: Login to ECR
        uses: docker/login-action@v1
        with:
          # your ecr details here
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Build and push container
        uses: docker/build-push-action@v2
        with:
          context: "${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:${{ env.CONTEXT_SUBDIR }}"
          push: true
          tags: ${{ env.ECR_REGISTRY }}/proxyco/madmax-api:stable

Read more comments on GitHub >

github_iconTop Results From Across the Web

github actions - issue in checkout action - Stack Overflow
When you want to use an action, you specify the action name and the version of the action to run. This line: -...
Read more >
git-pull Documentation - Git
Incorporates changes from a remote repository into the current branch. If the current branch is behind the remote, then by default it will...
Read more >
Git Pull | Atlassian Git Tutorial
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match...
Read more >
Why doesn't my GitHub Action run automatically from a fork ...
GitHub Actions and Pull Requests with Bdougie#30minutestomergeA quick tour of specific GitHub Actions triggers and their use, plus a deep ...
Read more >
How do I force git pull to overwrite local files? - Tower Git Client
The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found