-
Notifications
You must be signed in to change notification settings - Fork 0
33 lines (33 loc) · 1.13 KB
/
Copy pathdocker-image.yml
File metadata and controls
33 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: "Docker build and push"
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
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"
if: success()
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"
if: success()
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
eval $image;
done