0

When I make changes to my code and push the changes, the CI pipeline is triggered, and it builds and pushes the Docker image to the GitHub Container Registry. However, it seems that when I pull the image, the changes are not present. Am I doing something wrong in my CI workflow? Here's my file:

name: Continuous Integration

on:
  push:
    branches:
      - main

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Log in to the Container registry
        uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: ghcr.io/${{ github.repository_owner }}/myreponame:new

When I first change the tag of the image (here I have it set to "new"), I can see my new changes in my newly built image, but if I don't modify the tag, the changes don't get applied.

Here's my dockerfile if it can help:

# Build stage
FROM maven:3-openjdk-17-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app/pom.xml
COPY wait-for-it.sh /home/app/wait-for-it.sh
RUN chmod +x /home/app/wait-for-it.sh
RUN mvn -f /home/app/pom.xml clean package

# Package stage
FROM openjdk:17-alpine
RUN apk add --no-cache bash
COPY --from=build /home/app/target/api.jar /usr/local/lib/api.jar
COPY --from=build /home/app/wait-for-it.sh /usr/local/bin/wait-for-it.sh
ENTRYPOINT ["/usr/local/bin/wait-for-it.sh", "db:5432", "--", "java", "-jar", "/usr/local/lib/api.jar"]
Johni
  • 23
  • 4
  • Are you sure you're pulling the latest revision stored in the registry under the now re-tagged tag? Please add the instructions on how you compare the image revision for the new tag to your question so that it becomes more **concrete** what you ask about here. – hakre Apr 09 '23 at 14:19
  • pull_policy: always is not working as well – Johni Apr 09 '23 at 17:40
  • Please add all relevant information to your question, like the docker-compose.yml file. That works by [edit]ing the quesiton, the [help] has more detailed information. Possible duplicate of: https://stackoverflow.com/q/37685581/367456 – hakre Apr 09 '23 at 18:41

0 Answers0