Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Docker container using Github actions does not update package in github packages

The following .github workflow script does not update the packages ones deployed on Github packages.

After every deployment, I would like the script to update the packages deployed.

Here is my deploy script. Can someone please let me know how to modify it so a new package is created after every deploy?

name: Continuous Integration and Delivery

on: [ push ]

env:
  WEB_IMAGE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')/web
  NGINX_IMAGE: ghcr.io/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')/nginx

jobs:

  build:
    name: Build Docker Images
    runs-on: ubuntu-latest
    steps:
      - name: Log in to GitHub Packages
        run: echo ${PERSONAL_ACCESS_TOKEN} | docker login ghcr.io -u ${{ secrets.NAMESPACE }} --password-stdin
        env:
          PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
      - name: Build images
        run: |
          docker-compose down -v
          docker-compose -f docker-compose.ci.yml build
      - name: Push images
        run: |
          docker push ${{ env.WEB_IMAGE }}
          docker push ${{ env.NGINX_IMAGE }}

The github package only stays at the original time the initial push was and does not update the package. And upon inspecting, the code change is the original one and does not change to the new one.

enter image description here

On github actions, it shows that it has been successfully pushed

enter image description here

Here is docker.ci

version: "3.8"

services:
  web:
    build:
      context: ./app
      dockerfile: Dockerfile.prod
    image: "${WEB_IMAGE}"
    command: gunicorn hello_django.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/mediafiles
    expose:
      - 8000
    env_file: .env
  nginx:
    build:
      context: ./nginx
    image: "${NGINX_IMAGE}"
    volumes:
      - static_volume:/usr/src/app/staticfiles
      - media_volume:/usr/src/app/mediafiles
    ports:
      - 80:80
    depends_on:
      - web

volumes:
  static_volume:
  media_volume:
like image 289
Joseph Adam Avatar asked Feb 26 '26 14:02

Joseph Adam


1 Answers

The problem was the docker tag was not included on the push. I added the tags on the push and it was fixed.

The following is NOT enough, you must also add the tag to the push or else github repository will not update it for some reason.

  - name: Push images
    run: |
      docker push ${{ env.WEB_IMAGE }}
      docker push ${{ env.NGINX_IMAGE }}

You have to do the following

  - name: Push images
    run: |
      docker tag ${{ env.WEB_IMAGE }}  ${{ env.WEB_IMAGE_BASE }}:latest
      docker push ${{ env.WEB_IMAGE }}
      docker push ${{ env.WEB_IMAGE_BASE }}:latest
      docker tag ${{ env.NGINX_IMAGE }} ${{ env.NGINX_IMAGE_BASE }}:latest
      docker push ${{ env.NGINX_IMAGE }}
      docker push ${{ env.NGINX_IMAGE_BASE }}:latest
like image 163
Joseph Adam Avatar answered Mar 01 '26 13:03

Joseph Adam