first attempt at ci/cd
This commit is contained in:
parent
6a390af600
commit
6b2c302485
29
.gitea/workflows/main.yaml
Normal file
29
.gitea/workflows/main.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
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: |
|
||||
docker build \
|
||||
--tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} \
|
||||
--no-cache .
|
||||
- name: Push Docker image with run number tag
|
||||
run: |
|
||||
docker push $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}
|
||||
- name: Tag and push Docker image as latest if on master branch
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
docker tag $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }} $CONTAINER_NAME:latest
|
||||
docker push $CONTAINER_NAME:latest
|
||||
- name: Clean up docker images
|
||||
run: |
|
||||
docker rmi $CONTAINER_NAME:latest || true # Avoid failure if 'latest' tag does not exist
|
||||
docker rmi $CONTAINER_NAME:$MAJOR_VERSION.${{ github.run_number }}
|
Loading…
Reference in New Issue
Block a user