update-gitea-actions (!2)
Reviewed-on: https://git.avroid.tech/Templates/template-docker-repository/pulls/2 Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Co-committed-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
committed by
Aleksandr Vodyanov
parent
176bf2b6c5
commit
b1750866e2
@@ -1,9 +1,9 @@
|
|||||||
name: Build and publish docker image
|
name: Build and publish docker image
|
||||||
|
|
||||||
on:
|
on: [push]
|
||||||
push:
|
|
||||||
branches:
|
env:
|
||||||
- master
|
CI: ON
|
||||||
|
|
||||||
# Allow workflow to be manually run from the Gitea UI
|
# Allow workflow to be manually run from the Gitea UI
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -27,10 +27,17 @@ jobs:
|
|||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: "Build image and push"
|
- name: "Build image"
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
|
|
||||||
|
- name: "Push image"
|
||||||
|
run: |
|
||||||
make push
|
make push
|
||||||
|
if: ${{ gitea.ref == 'refs/heads/master' }}
|
||||||
|
|
||||||
|
- name: "Clear image"
|
||||||
|
run: |
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
@@ -39,3 +46,4 @@ jobs:
|
|||||||
git config user.email "svc-jenkins@avroid.tech"
|
git config user.email "svc-jenkins@avroid.tech"
|
||||||
git tag $(make getTag)
|
git tag $(make getTag)
|
||||||
git push origin $(make getTag)
|
git push origin $(make getTag)
|
||||||
|
if: ${{ gitea.ref == 'refs/heads/master' }}
|
||||||
|
|||||||
11
Makefile
11
Makefile
@@ -6,6 +6,12 @@ IMAGE_TAG = 1.0
|
|||||||
REVISION =
|
REVISION =
|
||||||
DOCKER_REGISTRY = harbor.avroid.tech
|
DOCKER_REGISTRY = harbor.avroid.tech
|
||||||
|
|
||||||
|
CI_FLAGS =
|
||||||
|
|
||||||
|
ifeq ($(CI), false)
|
||||||
|
CI_FLAGS = --no-cache
|
||||||
|
endif
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@echo 'DEFAULT:'
|
@echo 'DEFAULT:'
|
||||||
@echo ' make build'
|
@echo ' make build'
|
||||||
@@ -14,15 +20,12 @@ all:
|
|||||||
@echo ' make clean'
|
@echo ' make clean'
|
||||||
|
|
||||||
build:
|
build:
|
||||||
DOCKER_BUILDKIT=1 docker build \
|
DOCKER_BUILDKIT=1 docker build $(CI_FLAGS) \
|
||||||
-f Dockerfile \
|
-f Dockerfile \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
-t $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION) src/
|
-t $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION) src/
|
||||||
|
|
||||||
push:
|
push:
|
||||||
ifeq ($(CI), false)
|
|
||||||
docker login https://$(DOCKER_REGISTRY)
|
|
||||||
endif
|
|
||||||
docker push $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION)
|
docker push $(DOCKER_REGISTRY)/$(IMAGE_GROUP)/$(IMAGE_NAME):$(IMAGE_TAG)$(REVISION)
|
||||||
|
|
||||||
getTag:
|
getTag:
|
||||||
|
|||||||
Reference in New Issue
Block a user