base/.gitea/workflows/main.yaml

36 lines
1.2 KiB
YAML
Raw Permalink Normal View History

2024-02-09 02:03:55 +00:00
name: Base DNS Docker Image CI/CD Build
2024-02-09 02:15:46 +00:00
on:
- push
2024-02-09 02:03:55 +00:00
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
2024-02-09 02:22:12 +00:00
- name: Build Docker Image (with run number tag)
2024-02-09 02:03:55 +00:00
run: |
2024-02-10 07:22:02 +00:00
set -x
2024-02-09 02:03:55 +00:00
docker build \
--tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} \
2024-02-21 06:30:34 +00:00
--progress plain \
2024-02-09 02:03:55 +00:00
--no-cache .
2024-02-10 07:22:28 +00:00
- name: Push Docker Image (with run number tag)
2024-02-09 02:03:55 +00:00
run: |
2024-02-10 07:22:02 +00:00
set -x
2024-02-09 02:03:55 +00:00
docker push $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}
2024-02-09 02:22:12 +00:00
- name: Tag and Push `latest` Docker image (if main branch)
2024-02-09 02:18:54 +00:00
if: ${{ github.ref }} == 'refs/heads/main'
2024-02-09 02:03:55 +00:00
run: |
2024-02-10 07:22:02 +00:00
set -x
2024-02-09 02:03:55 +00:00
docker tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} $CONTAINER_NAME:latest
docker push $CONTAINER_NAME:latest
2024-02-09 02:22:12 +00:00
- name: Clean up Docker Images
2024-02-09 02:03:55 +00:00
run: |
2024-02-10 07:22:02 +00:00
set -x
2024-02-09 02:03:55 +00:00
docker rmi $CONTAINER_NAME:latest || true # Avoid failure if 'latest' tag does not exist
docker rmi $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}