-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (37 loc) · 1.36 KB
/
docker-build.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
name: Docker Build and Push
on:
push:
branches:
- dev # Adjust the branch name if needed
paths:
- '.env.test' #this trigger is for testing purposes only
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Load Environment Variables
run: |
if [ -f .env.test ]; then
export $(cat .env.test | grep -v '^#' | xargs)
fi
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BUILD=$BUILD" >> $GITHUB_ENV
echo "FIX=$FIX" >> $GITHUB_ENV
- name: Set Docker Tag
run: |
LOWER_CASE_GITHUB_REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')
echo "DOCKER_TAG_CUSTOM=ghcr.io/${LOWER_CASE_GITHUB_REPOSITORY}:$RELEASE-$VERSION.$BUILD.$FIX" >> $GITHUB_ENV
echo "$GITHUB_ENV"
- name: Remove README.md files
run: |
find . -name "README.md" -type f -delete
- name: Docker Build
run: |
docker image build --no-cache --tag $DOCKER_TAG_CUSTOM .
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push Docker image to ghcr
run: docker push $DOCKER_TAG_CUSTOM