base/.gitea/workflows/main.yaml
Donavan Fritz bf7d64bf44
All checks were successful
Base DNS Docker Image CI/CD Build / build-docker-image (push) Successful in 1m57s
easier to view builds in ci
2024-02-20 22:30:34 -08:00

36 lines
1.2 KiB
YAML

name: Base DNS Docker Image CI/CD Build
on:
- push
jobs:
build-docker-image:
runs-on: main
env:
CONTAINER_NAME: "${{ vars.CONTAINER_REGISTRY_HOSTNAME }}/dns/base"
MAJOR_VERSION: 0
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build Docker Image (with run number tag)
run: |
set -x
docker build \
--tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} \
--progress plain \
--no-cache .
- name: Push Docker Image (with run number tag)
run: |
set -x
docker push $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}
- name: Tag and Push `latest` Docker image (if main branch)
if: ${{ github.ref }} == 'refs/heads/main'
run: |
set -x
docker tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} $CONTAINER_NAME:latest
docker push $CONTAINER_NAME:latest
- name: Clean up Docker Images
run: |
set -x
docker rmi $CONTAINER_NAME:latest || true # Avoid failure if 'latest' tag does not exist
docker rmi $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}