Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit 1ce415b

Browse files
authored
Merge pull request #9 from TechTorque-2025/devOps
Dev ops
2 parents e4c5569 + 959fced commit 1ce415b

62 files changed

Lines changed: 3880 additions & 126 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# .github/workflows/build.yml
2+
# This workflow builds the JAR, then packages it as a Docker image.
3+
4+
on:
5+
push:
6+
branches:
7+
- 'main'
8+
- 'devOps'
9+
- 'dev'
10+
pull_request:
11+
branches:
12+
- 'main'
13+
- 'devOps'
14+
- 'dev'
15+
16+
# Permissions needed to push Docker images to your org's GitHub packages
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
jobs:
22+
# JOB 1: Your original job, unchanged
23+
build-test:
24+
name: Install and Build (Tests Skipped)
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up JDK 17
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: '17'
35+
distribution: 'temurin'
36+
cache: maven
37+
38+
- name: Cache Maven packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.m2/repository
42+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-
45+
46+
- name: Build with Maven (Skip Tests)
47+
# As requested, we are keeping -DskipTests for now
48+
run: mvn -B clean package -DskipTests --file auth-service/pom.xml
49+
50+
- name: Upload Build Artifact (JAR)
51+
# We upload the JAR so the next job can use it
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: auth-service-jar
55+
path: auth-service/target/*.jar
56+
57+
# JOB 2: New job to package the service as a Docker image
58+
build-and-push-docker:
59+
name: Build & Push Docker Image
60+
# This job only runs on pushes to 'main', not on PRs
61+
# Ensures you only publish final images for merged code
62+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/devOps' || github.ref == 'refs/heads/dev'
63+
runs-on: ubuntu-latest
64+
# This job runs *after* the build-test job succeeds
65+
needs: build-test
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
71+
# We need the JAR file that the 'build-test' job created
72+
- name: Download JAR Artifact
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: auth-service-jar
76+
path: auth-service/target/
77+
78+
# This action generates smart tags for your Docker image
79+
# e.g., 'ghcr.io/your-org/auth-service:latest'
80+
# e.g., 'ghcr.io/your-org/auth-service:a1b2c3d' (from the commit SHA)
81+
- name: Docker meta
82+
id: meta
83+
uses: docker/metadata-action@v5
84+
with:
85+
images: ghcr.io/${{ github.repository }} # e.g., ghcr.io/randitha/Authentication
86+
tags: |
87+
type=sha,prefix=
88+
type=raw,value=latest,enable={{is_default_branch}}
89+
90+
# Logs you into the GitHub Container Registry (GHCR)
91+
- name: Log in to GHCR
92+
uses: docker/login-action@v3
93+
with:
94+
registry: ghcr.io
95+
username: ${{ github.actor }}
96+
password: ${{ secrets.GITHUB_TOKEN }} # This token is auto-generated
97+
98+
# Builds the Docker image and pushes it to GHCR
99+
# This assumes you have a 'Dockerfile' in the root of 'Authentication'
100+
- name: Build and push Docker image
101+
uses: docker/build-push-action@v5
102+
with:
103+
context: . # Assumes Dockerfile is in the root of this repo
104+
# The Dockerfile build will copy the JAR from auth-service/target/
105+
push: true
106+
tags: ${{ steps.meta.outputs.tags }}
107+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/buildtest.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/deploy.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Authentication/.github/workflows/deploy.yml
2+
3+
name: Deploy Auth Service to Kubernetes
4+
5+
on:
6+
workflow_run:
7+
# This MUST match the 'name:' of your build.yml file
8+
workflows: ["Build and Package Service"]
9+
types:
10+
- completed
11+
branches:
12+
- 'main'
13+
- 'devOps'
14+
15+
jobs:
16+
deploy:
17+
name: Deploy Auth Service to Kubernetes
18+
# We only deploy if the build job was successful
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
# We only need the SHA of the new image
24+
- name: Get Commit SHA
25+
id: get_sha
26+
run: |
27+
echo "sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
28+
29+
# 1. Checkout your new 'k8s-config' repository
30+
- name: Checkout K8s Config Repo
31+
uses: actions/checkout@v4
32+
with:
33+
# This points to your new repo
34+
repository: 'TechTorque-2025/k8s-config'
35+
# This uses the org-level secret you created
36+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
37+
# We'll put the code in a directory named 'config-repo'
38+
path: 'config-repo'
39+
# --- NEW LINE ---
40+
# Explicitly checkout the 'main' branch
41+
ref: 'main'
42+
43+
- name: Install kubectl
44+
uses: azure/setup-kubectl@v3
45+
46+
- name: Install yq
47+
run: |
48+
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
49+
sudo chmod +x /usr/bin/yq
50+
51+
- name: Set Kubernetes context
52+
uses: azure/k8s-set-context@v4
53+
with:
54+
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} # This uses your Org-level secret
55+
56+
# 2. Update the image tag for the *authentication* service
57+
- name: Update image tag in YAML
58+
run: |
59+
yq -i '(select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "ghcr.io/techtorque-2025/authentication:${{ steps.get_sha.outputs.sha }}"' config-repo/k8s/services/auth-deployment.yaml
60+
61+
# --- NEW DEBUGGING STEP ---
62+
- name: Display file contents before apply
63+
run: |
64+
echo "--- Displaying k8s/services/auth-deployment.yaml ---"
65+
cat config-repo/k8s/services/auth-deployment.yaml
66+
echo "------------------------------------------------------"
67+
68+
# 3. Deploy the updated file
69+
- name: Deploy to Kubernetes
70+
run: |
71+
kubectl apply -f config-repo/k8s/services/auth-deployment.yaml
72+
kubectl rollout status deployment/auth-deployment

.idea/workspace.xml

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)