Skip to content

dcarbone/install-jq-action github action. #14

dcarbone/install-jq-action github action.

dcarbone/install-jq-action github action. #14

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: "Install jq"
uses: dcarbone/install-jq-action@v3
with:
version: '1.7.1'
- 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: |
jq -r 'map(select(.build == true)).[]
| .stages[] as $stage
| docker build --no-cache --target \($stage) -t \(.namespace)/\(.repository):\(.tag)-\($stage|ascii_downcase) ./\(.path)
| split('\n') | .[]' versions.json | while read -r image; do
$($image)
done
- name: "Push Images"
run: |
jq -r 'map(select(.build == true and .push == true)).[]
| .stages[] as $stage
| docker push \(.namespace)/\(.repository):\(.tag)-\($stage|ascii_downcase)
| split('\n') | .[]' versions.json | while read -r image; do
$($image)
done