-
Notifications
You must be signed in to change notification settings - Fork 7
82 lines (74 loc) · 2.04 KB
/
build-docker-container.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
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
77
78
79
80
81
82
---
name: Build and Publish Docker Container
on:
workflow_dispatch:
inputs:
docker-name:
required: true
type: string
default: fac
image-name:
required: true
type: string
default: web-container
repo-name:
required: true
type: string
default: gsa-tts/fac
work-dir:
required: true
type: string
default: ./backend
workflow_call:
inputs:
docker-name:
required: true
type: string
default: fac
image-name:
required: true
type: string
default: web-container
repo-name:
required: true
type: string
default: gsa-tts/fac
work-dir:
required: true
type: string
default: ./backend
env:
DOCKER_NAME: ${{ inputs.docker-name }}
IMAGE: ${{ inputs.image-name }}
GH_REPO: ${{ inputs.repo-name }}
WORKING_DIRECTORY: ${{ inputs.work-dir }}
jobs:
build-with-docker:
name: Build Docker Container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Get Date
shell: bash
id: date
run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build Container
working-directory: ${{ env.WORKING_DIRECTORY }}
run: docker build -t ${{ env.DOCKER_NAME }}:${{ steps.date.outputs.date }} .
- name: Tag Image
run: docker tag ${{ env.DOCKER_NAME }}:${{ steps.date.outputs.date }} ghcr.io/${{ env.GH_REPO }}/${{ env.IMAGE }}:latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Web Container
run: docker push --all-tags ghcr.io/${{ env.GH_REPO }}/${{ env.IMAGE }}