Skip to content

CD Pipeline

CD Pipeline #11

name: CD Pipeline
on:
release:
types: [published]
jobs:
push:
name: Push Docker Image to Registry
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v2
# Step 2: Set up Docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 3: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Step 4: Extract version from release tag
- name: Extract Version from Release Tag
run: |
VERSION=${GITHUB_REF##*/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Step 5: Build Docker Image
- name: Build Docker Image
run: |
# Build Docker image
docker build -t narmidm/k8s-pod-cpu-stressor:latest -f docker/Dockerfile .
# Tag the Docker image with the release version
docker tag narmidm/k8s-pod-cpu-stressor:latest narmidm/k8s-pod-cpu-stressor:${{ env.VERSION }}
# Step 6: Push Docker Image with Latest and Version Tags
- name: Push Docker Image
run: |
# Ensure the image is built and tagged successfully
docker images
# Push Docker image with latest tag
docker push narmidm/k8s-pod-cpu-stressor:latest
# Push Docker image with version tag
docker push narmidm/k8s-pod-cpu-stressor:${{ env.VERSION }}