Skip to content

fixing jq command docker-image.yml. #6

fixing jq command docker-image.yml.

fixing jq command docker-image.yml. #6

Workflow file for this run

name: "Docker build and push"
on:
push:
branches: [ "master" ]
jobs:
build_and_push:
runs-on: ubuntu-22.04
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v4
- name: "Build images"
run: |
buildExpr='map(select(.build == true)).[] | .stages[] as $stage | "docker build --no-cache --target \($stage) -t \(.namespace)/\(.name):\(.tag)-\($stage|ascii_downcase) ./\(.path)" | split("\n") | .[]';
jq -r "$buildExpr" versions.json | while read -r image; do
$($image)
done
- name: "Push Images"
run: |
pushExpr='map(select(.build == true and .push == true)).[] | .stages[] as $stage | "docker push \(.namespace)/\(.name):\(.tag)-\($stage|ascii_downcase) " | split("\n") | .[]'
jq -r "$pushExpr" versions.json | while read -r image; do
$($image)
done