Add action
Some checks failed
Build and Publish / publish image (push) Successful in 31s
Build and Publish / deploy image (push) Failing after 15s

This commit is contained in:
Guilherme 2024-09-25 20:54:27 +02:00
parent 1a77505ef5
commit 13618adfa8
2 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,72 @@
# check this out: https://www.programonaut.com/how-to-deploy-a-docker-image-to-a-server-using-github-actions/
name: Build and Publish
run-name: ${{ gitea.actor }} is building docker image for thekendienstbot out Gitea Actions
on: push
# on:
# push:
# branches: [ "main" ]
env:
REGISTRY: gitea.lan.hobbyhimmel.de
OWNER: ${{ github.repository_owner }}
CONTAINER_NAME: thekendienstbot
IMAGE_NAME: ${{ env.OWNER }}/${{ env.CONTAINER_NAME }}
jobs:
publish:
name: publish image
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
#- name: Login
#run: echo ${{ secrets.BUILD_ACTION }} | docker login ${{ env.REGISTRY }} -u gitea --password-stdin
- name: Login to gitea
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.date.outputs.date }}-${{ env.GITHUB_SHA }}
# - name: Build
#run: |
# echo "build ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} done"
# docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} .
#
#- name: Publish
#run:# |
#docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
deploy:
needs: publish
name: deploy image
runs-on: backend_local
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Delete Container
working-directory: ./docker
run: |
docker container rm -f ${{ env.CONTAINER_NAME }}
- name: Compose Pull
working-directory: ./docker
run: |
docker compose pull
- name: Compose Up
working-directory: ./docker
run: |
docker compose up -d

View File

@ -5,7 +5,7 @@ services:
context: ../ context: ../
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
image: thekendienstbot:latest image: gitea.lan.hobbyhimmmel.de/guibufolo/thekendienstbot:latest
container_name: thekendienstbot container_name: thekendienstbot
environment: environment:
- TZ=Europe/Berlin - TZ=Europe/Berlin