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.

Add option to choose between git or workflow context to generate metadata

See original GitHub issue

Behaviour

I have a workflow that checks out the latest tag and rebuilds the Docker image if the base image was updated. Context info contains info from master:

Context info
  eventName: schedule
  sha: 1c0577d958b4b4bed278593872a3c29f02981a0d
  ref: refs/heads/master
  workflow: Update Docker Images
  action: meta
  actor: lucacome
  runNumber: 134
  runId: 1335539062

Steps to reproduce this issue

  1. Run the workflow on a schedule
  2. Checkout a tag
  3. The sha is not the correct one

Expected behavior

org.opencontainers.image.revision contains the sha from the tag that was checked out

Actual behaviour

org.opencontainers.image.revision contains the sha from the latest commit on master

Configuration

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
        with:
          ref: v${{ needs.variables.outputs.kic-tag }}

       ....
 
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: |
            nginx/nginx-ingress
            ghcr.io/nginxinc/kubernetes-ingress
          flavor: |
            latest=true
            suffix=...not relevant...
          tags: |
            type=raw,value=${{ needs.variables.outputs.kic-tag }}
            type=raw,value=${{ steps.tag.outputs.short }}
          labels: ...not relevant...

Logs

logs_11965.zip

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
DanHorrocksBurgesscommented, Dec 2, 2021

I will think about it, maybe something like:

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v3
        with:
          context: <workflow|git>

If I could +1 this, I’d be very much interested in it too!

5reactions
crazy-maxcommented, Oct 13, 2021

@lucacome

there’s always a checkout in the job

Not always. You can build a Docker image using a Git context so it does not require the checkout step.

Maybe an input flag to enable getting the info from the current commit? Just throwing it out there 😄

Yeah I understand what you mean but the action heavily relies on the current context via the hydrated Octokit client (aka @actions/github).

I will think about it, maybe something like:

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v3
        with:
          context: <workflow|git>
Read more comments on GitHub >

github_iconTop Results From Across the Web

git-config Documentation - Git
git -config - Get and set repository or global options ... Take the configuration from the given files instead from global or system-level...
Read more >
Field Reference - The workflow engine for Kubernetes
External Fields¶. ObjectMeta¶. ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. Examples with this ...
Read more >
EGit/User Guide - Eclipsepedia
1.3.1 Create Local Repository; 1.3.2 Create Repository at GitHub ... If you selected one of the options to use Git from the Command...
Read more >
How to Create a Custom GitHub Action with Node & JavaScript
GitHub Actions are a powerful tool to automate all kinds of tasks in your workflow. While there are a ton of options available...
Read more >
Context Object - AWS Step Functions
You can access the context object from the following fields: InputPath. OutputPath. ItemsPath (in Map states). Variable (in Choice states). ResultSelector.
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