dcarbone/install-jq-action github action. #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |