-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
46 lines (43 loc) · 1.42 KB
/
action.yaml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
name: 'docker-build'
description: 'Build and Push Docker Images automatically'
inputs:
token:
description: 'GitHub Token'
required: true
timezone:
description: 'Timezone for creating timestamps to include in image tag'
required: true
default: 'UTC'
args:
description: 'Configuration values for building images'
required: true
runs:
using: 'composite'
steps:
- name: 'Get docker build args'
id: js_action
uses: kengo-k/actions-docker-build/internal/get@main
with:
token: ${{ inputs.token }}
timezone: ${{ inputs.timezone }}
args: ${{ inputs.args }}
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.token }}
- name: Checkout latest commit
uses: actions/checkout@v4
- name: 'Build and Push Docker Images'
shell: bash
run: |
build_args='${{ steps.js_action.outputs.build_args }}'
echo "$build_args" | jq -c '.[]' | while read -r element; do
path=$(echo "$element" | jq -r '.path')
name=$(echo "$element" | jq -r '.name')
tag=$(echo "$element" | jq -r '.tag')
echo "path: $path, name: $name, tag: $tag"
docker build -t ghcr.io/${{ github.actor }}/$name:$tag -f $path $(dirname $path)
docker push ghcr.io/${{ github.actor }}/$name:$tag
done