44 lines
1.2 KiB
YAML
44 lines
1.2 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Normalize repo name
|
|
run: |
|
|
REPOSITORY_LC=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
|
echo "REPOSITORY_LC=REPOSITORY_LC" >> $GITHUB_ENV
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: eiche:3000
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build Docker Image
|
|
env:
|
|
REGESTRY: eiche:3000
|
|
run: |
|
|
# Build the image with the commit hash tag
|
|
docker build -t ${REGISTRY}/${REPOSITORY_LC}:${GITHUB_RUN_NUMBER} .
|
|
|
|
# Tag the same image as "latest"
|
|
docker tag ${REGISTRY}/${REPOSITORY_LC}:${GITHUB_RUN_NUMBER} ${REGISTRY}/${REPOSITORY_LC}:latest
|
|
|
|
- name: Push Docker Images
|
|
env:
|
|
REGESTRY: eiche:3000
|
|
run: |
|
|
docker push ${REGISTRY}/${REPOSITORY_LC}:${GITHUB_RUN_NUMBER}
|
|
docker push ${REGISTRY}/${REPOSITORY_LC}:latest
|
|
|
|
- name: Log out from registry
|
|
if: always()
|
|
run: docker logout eiche:3000 |