mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 04:45:36 -04:00
adding devops
used gemini to create the k8s/dockerfiles faster
This commit is contained in:
parent
5c09c5a22f
commit
6c14a968c3
74 changed files with 2061 additions and 16 deletions
77
.github/workflows/build.yml
vendored
Normal file
77
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
name: Build Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
# Checkout the repository
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Log into the GitHub Container Registry
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Define the list of project directories
|
||||
- name: Set project list
|
||||
id: set_projects
|
||||
run: |
|
||||
echo "projects<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "admin-dashboard" >> $GITHUB_OUTPUT
|
||||
echo "battleship" >> $GITHUB_OUTPUT
|
||||
echo "calculator" >> $GITHUB_OUTPUT
|
||||
echo "cv" >> $GITHUB_OUTPUT
|
||||
echo "cv-project" >> $GITHUB_OUTPUT
|
||||
echo "inventory" >> $GITHUB_OUTPUT
|
||||
echo "library" >> $GITHUB_OUTPUT
|
||||
echo "messages" >> $GITHUB_OUTPUT
|
||||
echo "nodejs-mini-message-board" >> $GITHUB_OUTPUT
|
||||
echo "portfolio" >> $GITHUB_OUTPUT
|
||||
echo "restaurant" >> $GITHUB_OUTPUT
|
||||
echo "shopping-cart" >> $GITHUB_OUTPUT
|
||||
echo "signup_form" >> $GITHUB_OUTPUT
|
||||
echo "tictactoe" >> $GITHUB_OUTPUT
|
||||
echo "todo" >> $GITHUB_OUTPUT
|
||||
echo "weather" >> $GITHUB_OUTPUT
|
||||
echo "auth-expressjs" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
# Build and push Docker images for changed projects
|
||||
- name: Build and push Docker images
|
||||
id: build_push
|
||||
env:
|
||||
PROJECTS: ${{ steps.set_projects.outputs.projects }}
|
||||
run: |
|
||||
# Loop through each project directory
|
||||
for project in $(cat <<< "$PROJECTS"); do
|
||||
# Check if the project has changes
|
||||
if git diff --quiet HEAD^ HEAD -- "$project" || git diff --quiet HEAD^ HEAD -- "${project}/devops"; then
|
||||
echo "Changes detected in project: $project"
|
||||
# Set the image name dynamically using github context
|
||||
image_name="ghcr.io/${{ github.repository_owner }}/$project:${{ github.sha }}"
|
||||
# Build the docker image
|
||||
echo "Building image: $image_name"
|
||||
docker build -t "$image_name" "$project/devops"
|
||||
# Push the docker image to the github container registry
|
||||
echo "Pushing image: $image_name"
|
||||
docker push "$image_name"
|
||||
else
|
||||
echo "No changes detected in project: $project"
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue