forked from mehdihadeli/food-delivery-microservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
47 lines (41 loc) · 1.95 KB
/
action.yml
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
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
# https://doug.sh/posts/using-composite-actions-with-github-actions/
# https://wallis.dev/blog/composite-github-actions
name: "Docker Build"
description: "Docker Build"
# Input parameters allow you to specify data that the action expects to use during runtime. GitHub stores input parameters as environment variables.(so they are just string)
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
inputs:
docker-file-path:
description: Docker file path
required: true
service-name:
description: Service name
required: true
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-actions
runs:
using: "composite"
steps:
- name: Info
shell: bash
run: |
echo actor is: "${{ github.actor }}"
echo docker-file-path is: "${{ inputs.docker-file-path }}"
echo service-name is: "${{ inputs.service-name }}"
- name: Set branch name as env variable
shell: bash
run: |
if [ ${{ github.event_name }} = 'workflow_run' ]; then
echo "BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV
else
echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
fi
# https://docs.docker.com/engine/reference/commandline/build/
# https://dev.to/willvelida/pushing-container-images-to-github-container-registry-with-github-actions-1m6b
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
- name: docker build
shell: bash
if: success()
run: |
docker build . --tag ${{ inputs.service-name }}:latest -f "${{ inputs.docker-file-path }}"