-
Notifications
You must be signed in to change notification settings - Fork 14
77 lines (60 loc) · 2 KB
/
Copy pathbuild-docker.yaml
File metadata and controls
77 lines (60 loc) · 2 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Build docker image
on:
workflow_call:
inputs:
microservice_name:
required: true
type: string
description: "Specify microservice name from docker-compose.yaml"
env:
IMAGE_TAG: ''
BUILD_CONTEXT: ''
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Delete hostedtoolscache
run: rm -rf /opt/hostedtoolcache
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.12
- name: Install pyyaml python package
run: pip install pyyaml
- name: Get image name
run: |
echo "IMAGE_TAG=$(python .github/scripts/parse_compose_service_image.py ${{ inputs.microservice_name }})" >> $GITHUB_ENV
- name: Get image build context
run: |
echo "BUILD_CONTEXT=$(python .github/scripts/parse_compose_service_build_context.py ${{ inputs.microservice_name }})" >> $GITHUB_ENV
- name: Get image build Dockerfile
run: |
echo "DOCKERFILE=$(python .github/scripts/parse_compose_service_dockerfile.py ${{ inputs.microservice_name }})" >> $GITHUB_ENV
- name: Image name
run: echo "$IMAGE_TAG"
- name: Build context
run: echo "$BUILD_CONTEXT"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ env.BUILD_CONTEXT }}
file: ${{ env.BUILD_CONTEXT }}/${{ env.DOCKERFILE }}
push: false
tags: ${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max