Skip to content

Update .original-images.yaml #2

Update .original-images.yaml

Update .original-images.yaml #2

name: Retag and Build Images to GHCR
on:
push:
branches:
- image-cicd
paths:
- '.original-images.yaml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
retag-images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 3
matrix:
image: []

Check failure on line 23 in .github/workflows/image-pull-and-tag.yaml

View workflow run for this annotation

GitHub Actions / Retag and Build Images to GHCR

Invalid workflow file

The workflow is not valid. .github/workflows/image-pull-and-tag.yaml (Line: 23, Col: 16): Matrix vector 'image' does not contain any values
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Read images from file and set matrix
id: read-images
run: |
if [ ! -f .original-images.yaml ]; then
echo "File .original-images.yaml not found!"
exit 1
fi
echo "Reading images from .original-images.yaml"
images=$(yq '.[]' .original-images.yaml)
json_matrix=$(echo "$images" | jq -R -s -c 'split("\n") | map(select(length > 0) | split(":") | {path: .[0], tag: .[1]})')
echo "matrix=$json_matrix" >> $GITHUB_ENV
- name: Dynamically update matrix
uses: actions/github-script@v6
with:
script: |
const matrix = JSON.parse(process.env.matrix);
return { matrix };
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/$(basename ${{ matrix.image.path }}):${{ matrix.image.tag }}
build-args: |
BASE_IMAGE=${{ matrix.image.path }}
BASE_TAG=${{ matrix.image.tag }}
- name: Logout from Docker
run: docker logout ${{ env.REGISTRY }}