69 lines
1.8 KiB
YAML
69 lines
1.8 KiB
YAML
name: Build and Publish
|
|
run-name: ${{ gitea.actor }} is building docker image for thekendienstbot out Gitea Actions
|
|
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 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
|
|
provenance: false
|
|
tags: |
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.date.outputs.date }}-${{ env.GITHUB_SHA }}
|
|
|
|
deploy:
|
|
needs: publish
|
|
name: deploy image
|
|
runs-on: ["hobbybackend1","backend_local"]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Login to gitea
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.TOKEN_GITEA }}
|
|
|
|
- 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
|