Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] In multi-stage builds, incorrect latest tag pushed #129

Closed
travier opened this issue Oct 6, 2023 · 3 comments
Closed

[BUG] In multi-stage builds, incorrect latest tag pushed #129

travier opened this issue Oct 6, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@travier
Copy link

travier commented Oct 6, 2023

Version

redhat-actions/push-to-registry@v2

Describe the bug

Using this action with a multi-stage build and pushing to the latest tag, the wrong tag is pushed and latest tag from the first stage image is pushed instead.

Steps to reproduce, workflow links, screenshots

Containerfile:

FROM docker.io/filebrowser/filebrowser:latest

# Keep container image for ~6 months
LABEL quay.expires-after=24w

# Run unprivileged
USER 2000:2000

# Disable healthchecks
HEALTHCHECK NONE

GitHub Action:

name: "Build Filebrowser image"

env:
  IMAGE_NAME: "filebrowser"
  REGISTRY: "quay.io/travier"

on:
  pull_request:
    branches:
      - main
    paths:
      - filebrowser/*
      - .github/workflows/filebrowser.yml
  push:
    branches:
      - main
    paths:
      - filebrowser/*
      - .github/workflows/filebrowser.yml
  schedule:
    - cron:  '0 0 * * MON'

permissions: read-all

# Prevent multiple workflow runs from racing to ensure that pushes are made
# sequentialy for the main branch. Also cancel in progress workflow runs for
# pull requests only.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  build-push-image:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Build container image
        uses: redhat-actions/buildah-build@v2
        with:
          context: ${{ env.IMAGE_NAME }}
          image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: latest ${{ github.sha }}
          containerfiles: ${{ env.IMAGE_NAME }}/Containerfile
          layers: false
          oci: true

      - name: Push to Quay.io
        uses: redhat-actions/push-to-registry@v2
        if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/main'
        with:
          username: ${{ secrets.BOT_USERNAME }}
          password: ${{ secrets.BOT_SECRET }}
          image: ${{ env.IMAGE_NAME }}
          registry: ${{ env.REGISTRY }}
          tags: latest ${{ github.sha }}

From travier/quay-containerfiles@be393e6

@travier travier added the bug Something isn't working label Oct 6, 2023
@travier
Copy link
Author

travier commented Oct 6, 2023

Job: https://github.com/travier/quay-containerfiles/actions/runs/6430376470/job/17462161445

It looks like the issue is that the image name is not fully qualified with the registry name when pushing.

@travier
Copy link
Author

travier commented Oct 6, 2023

So this looks like an issue in https://github.com/redhat-actions/push-to-registry instead.

@travier
Copy link
Author

travier commented Oct 6, 2023

OK, it appears that needed to not fully qualify the image name in the build step instead.: travier/quay-containerfiles@6378604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant