From d1e80a7ff039082a07d2e6962caeddc7b4b0c724 Mon Sep 17 00:00:00 2001 From: Raoul Scarazzini Date: Fri, 4 Aug 2023 17:01:45 +0200 Subject: [PATCH] Fix container image build&push process using tags This commit changes several things related to the build & push process: - Use the fixed ghcr.io/mmul-it/kpa-marp-pandoc:v1.0.0 base container release. - Use the branch name as the tag for the generated image (adding also latest). - Push on both ghcr.io and quay.io the same container images with same tags. --- .github/workflows/main.yml | 30 +++++++++++++++++++----------- Dockerfile | 4 ++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f1956b..4634073 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: Linter, test, build and push KPA container env: KPA_PROJECT: example - REGISTRY_NAME: ghcr.io - CONTAINER_NAME: mmul-it/kpa - CONTAINER_VERSION: latest + REGISTRY_GHCR: ghcr.io/mmul-it + REGISTRY_QUAY: quay.io/mmul + CONTAINER_NAME: kpa on: [push] @@ -12,7 +12,7 @@ jobs: linter: runs-on: ubuntu-latest container: - image: ghcr.io/mmul-it/kpa-marp-pandoc + image: ghcr.io/mmul-it/kpa-marp-pandoc:v1.0.0 steps: - name: Checkout repository uses: actions/checkout@v3 @@ -30,7 +30,7 @@ jobs: test: runs-on: ubuntu-latest container: - image: ghcr.io/mmul-it/kpa-marp-pandoc + image: ghcr.io/mmul-it/kpa-marp-pandoc:v1.0.0 needs: linter steps: - name: Checkout repository @@ -41,7 +41,6 @@ jobs: --roles-path ./playbooks/roles - name: Generate markdown and pdf files run: for KPA_DOC in $(ls projects/${KPA_PROJECT}/*.yml); do - echo "Processing ${TRAINING}"; ansible-playbook -e @projects/${KPA_PROJECT}/common/settings.yml -e @${KPA_DOC} @@ -64,8 +63,17 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the container image - run: docker build . --file Dockerfile --tag ${REGISTRY_NAME}/${CONTAINER_NAME}:${CONTAINER_VERSION} - - name: Login into the container registry - run: echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ vars.GHCR_USER }} --password-stdin - - name: Push the image into the container registry - run: docker push ${REGISTRY_NAME}/${CONTAINER_NAME}:${CONTAINER_VERSION} + run: docker build . + --file Dockerfile + --tag ${REGISTRY_GHCR}/${CONTAINER_NAME}:${{ github.ref_name }} + --tag ${REGISTRY_GHCR}/${CONTAINER_NAME}:latest + --tag ${REGISTRY_QUAY}/${CONTAINER_NAME}:${{ github.ref_name }} + --tag ${REGISTRY_QUAY}/${CONTAINER_NAME}:latest + - name: Login into the GitHub Container Registry + run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ${REGISTRY_GHCR} --username "${{ vars.GHCR_USER }}" --password-stdin + - name: Login into the Quay Container Registry + run: echo "${{ secrets.QUAY_ROBOT_TOKEN }}" | docker login ${REGISTRY_QUAY} --username "${{ vars.QUAY_ROBOT_NAME }}" --password-stdin + - name: Push the image into the GitHub Container Registry + run: docker push --all-tags ${REGISTRY_GHCR}/${CONTAINER_NAME} + - name: Push the image into the Quay Container Registry + run: docker push --all-tags ${REGISTRY_QUAY}/${CONTAINER_NAME} diff --git a/Dockerfile b/Dockerfile index 28bd9e2..c11ae23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Dockerfile for KPA project to be used in CI -# Start from ansible-core -FROM quay.io/mmul/kpa-marp-pandoc +# Start from kpa-marp-pandoc +FROM ghcr.io/mmul-it/kpa-marp-pandoc:v1.0.0 # Create workdir path RUN mkdir /kpa