-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (42 loc) · 1.27 KB
/
_docker-build-image.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
48
49
50
name: Build Docker image
on:
workflow_call:
inputs:
app-name:
required: true
type: string
org-name:
type: string
default: gsa-tts
repo-name:
type: string
default: ${{ github.event.repository.name }}
tag-name:
type: string
default: ${{ github.ref_name }}
env:
TAG_NAME: ${{ inputs.tag-name }}
APP_DIR: ${{ inputs.app-name }}
REGISTRY_PATH: ghcr.io/${{ inputs.org-name }}/${{ inputs.repo-name }}/${{ inputs.app-name }}
COMMIT_SHA: ${{github.sha}}
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build . --platform linux/amd64 --target app --build-arg APP_DIR=${APP_DIR} --tag ${REGISTRY_PATH}:${COMMIT_SHA}
- name: Tag Docker image
run: |
docker tag ${REGISTRY_PATH}:${COMMIT_SHA} ${REGISTRY_PATH}:${TAG_NAME}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to container registry
run: |
docker push --all-tags ${REGISTRY_PATH}