Skip to content

Commit

Permalink
Fix container image build&push process using tags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rascasoft committed Aug 4, 2023
1 parent a67d8cf commit d1e80a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ 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]

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
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d1e80a7

Please sign in to comment.