-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,33 +1,33 @@ | ||||||||||||||||||||||||||||||||
| # .github/workflows/build.yml | ||||||||||||||||||||||||||||||||
| # This workflow builds the JAR, then packages it as a Docker image. | ||||||||||||||||||||||||||||||||
| # Updated build.yaml template for microservices | ||||||||||||||||||||||||||||||||
| # This replaces the old build.yaml to add branch-aware image tagging | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| name: Build and Package Service | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||
| - 'main' | ||||||||||||||||||||||||||||||||
| - 'devOps' | ||||||||||||||||||||||||||||||||
| - 'dev' | ||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||
| - 'main' | ||||||||||||||||||||||||||||||||
| - 'devOps' | ||||||||||||||||||||||||||||||||
| - 'dev' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Permissions needed to push Docker images to your org's GitHub packages | ||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||
| packages: write | ||||||||||||||||||||||||||||||||
| packages: write | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| # JOB 1: Your original job, unchanged | ||||||||||||||||||||||||||||||||
| # JOB 1: Build and test (runs on all pushes and PRs) | ||||||||||||||||||||||||||||||||
| build-test: | ||||||||||||||||||||||||||||||||
| name: Install and Build (Tests Skipped) | ||||||||||||||||||||||||||||||||
| name: Build and Test | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # For Java/Spring Boot services: | ||||||||||||||||||||||||||||||||
| - name: Set up JDK 17 | ||||||||||||||||||||||||||||||||
| uses: actions/setup-java@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
|
|
@@ -43,65 +43,94 @@ jobs: | |||||||||||||||||||||||||||||||
| restore-keys: | | ||||||||||||||||||||||||||||||||
| ${{ runner.os }}-maven- | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Build with Maven (Skip Tests) | ||||||||||||||||||||||||||||||||
| # As requested, we are keeping -DskipTests for now | ||||||||||||||||||||||||||||||||
| - name: Build with Maven | ||||||||||||||||||||||||||||||||
| run: mvn -B clean package -DskipTests --file auth-service/pom.xml | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Upload Build Artifact (JAR) | ||||||||||||||||||||||||||||||||
| # We upload the JAR so the next job can use it | ||||||||||||||||||||||||||||||||
| - name: Upload Build Artifact | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: auth-service-jar | ||||||||||||||||||||||||||||||||
| name: service-jar | ||||||||||||||||||||||||||||||||
| path: auth-service/target/*.jar | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # JOB 2: New job to package the service as a Docker image | ||||||||||||||||||||||||||||||||
| # For Node.js/Next.js services (Frontend): | ||||||||||||||||||||||||||||||||
| # - name: Use Node.js and cache npm | ||||||||||||||||||||||||||||||||
| # uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||
| # with: | ||||||||||||||||||||||||||||||||
| # node-version: '22' | ||||||||||||||||||||||||||||||||
| # cache: 'npm' | ||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||
| # - name: Install dependencies | ||||||||||||||||||||||||||||||||
| # run: npm ci | ||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||
| # - name: Run linter | ||||||||||||||||||||||||||||||||
| # run: npm run lint | ||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||
| # - name: Build | ||||||||||||||||||||||||||||||||
| # run: npm run build | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+70
|
||||||||||||||||||||||||||||||||
| # For Node.js/Next.js services (Frontend): | |
| # - name: Use Node.js and cache npm | |
| # uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: '22' | |
| # cache: 'npm' | |
| # | |
| # - name: Install dependencies | |
| # run: npm ci | |
| # | |
| # - name: Run linter | |
| # run: npm run lint | |
| # | |
| # - name: Build | |
| # run: npm run build |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent artifact naming between upload and download. The artifact is uploaded with name service-jar (line 52) but this creates a potential issue if the workflow template is copied across multiple repositories without changes, as artifact names should be unique within a workflow run. Both occurrences should use a consistent, repository-specific naming pattern.
| name: service-jar | |
| name: service-jar-${{ github.event.repository.name }} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded repository-specific image name. The image name ghcr.io/techtorque-2025/authentication is hardcoded and specific to this authentication service. For a reusable template workflow (as indicated by the file comments), this should use github.repository_owner and derive the service name dynamically. For example:
images: ghcr.io/${{ github.repository }}This would make the workflow truly reusable across microservices.
| images: ghcr.io/techtorque-2025/authentication | |
| images: ghcr.io/${{ github.repository }} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid type=raw syntax with Docker metadata action. The {{sha}} placeholder syntax is not valid for type=raw in docker/metadata-action v5. For raw tags, you need to use the format with prefix or construct the full value using available variables. The correct approach would be:
type=raw,value=${{ steps.branch.outputs.name }}-{{sha}}However, {{sha}} is only available for certain tag types like type=sha. Consider using:
type=sha,prefix=${{ steps.branch.outputs.name }}-,format=short| type=raw,value=${{ steps.branch.outputs.name }}-{{sha}},enable=true | |
| type=sha,prefix=${{ steps.branch.outputs.name }}-,format=short,enable=true |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flavor: latest=false configuration conflicts with the latest tag definition. On line 105, you explicitly create a latest tag for the default branch, but then on line 107 you set flavor: latest=false. This configuration is contradictory. If you want to control the latest tag manually (as you're doing on line 105), the flavor: latest=false is correct. However, verify this is the intended behavior, as it may cause confusion.
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation notes should not be in production workflow files. Lines 133-136 contain replacement instructions that are meant for developers implementing this template. These comments should either be:
- Removed once the workflow is configured for a specific service, or
- Moved to a separate README or documentation file
Having these in the workflow file suggests this is still a template that hasn't been properly customized for the authentication service.
| # REPLACEMENTS NEEDED: | |
| # - auth-service: e.g., "auth-service", "time-logging-service" (for Java services) | |
| # - authentication: e.g., "authentication", "timelogging_service", "frontend_web" | |
| # - Uncomment Node.js steps for Frontend_Web |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||||||
| # Authentication/.github/workflows/deploy.yml | ||||||||||||
|
|
||||||||||||
| name: Deploy Auth Service to Kubernetes | ||||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| workflow_run: | ||||||||||||
| # This MUST match the 'name:' of your build.yml file | ||||||||||||
| workflows: ["Build and Package Service"] | ||||||||||||
| types: | ||||||||||||
| - completed | ||||||||||||
| branches: | ||||||||||||
| - 'main' | ||||||||||||
| - 'devOps' | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: devOps branch removed from build.yaml. This workflow triggers on the Either update build.yaml to include devOps or remove this branch reference: branches:
- 'main'
- - 'devOps'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| deploy: | ||||||||||||
| name: Deploy Auth Service to Kubernetes | ||||||||||||
| # We only deploy if the build job was successful | ||||||||||||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
|
|
||||||||||||
| steps: | ||||||||||||
| # We only need the SHA of the new image | ||||||||||||
| - name: Get Commit SHA | ||||||||||||
| id: get_sha | ||||||||||||
| run: | | ||||||||||||
| echo "sha=$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT | ||||||||||||
|
|
||||||||||||
| # 1. Checkout your new 'k8s-config' repository | ||||||||||||
| - name: Checkout K8s Config Repo | ||||||||||||
| uses: actions/checkout@v4 | ||||||||||||
| with: | ||||||||||||
| # This points to your new repo | ||||||||||||
| repository: 'TechTorque-2025/k8s-config' | ||||||||||||
| # This uses the org-level secret you created | ||||||||||||
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||||||||||||
| # We'll put the code in a directory named 'config-repo' | ||||||||||||
| path: 'config-repo' | ||||||||||||
| # --- NEW LINE --- | ||||||||||||
| # Explicitly checkout the 'main' branch | ||||||||||||
| ref: 'main' | ||||||||||||
|
|
||||||||||||
| - name: Install kubectl | ||||||||||||
| uses: azure/setup-kubectl@v3 | ||||||||||||
|
|
||||||||||||
| - name: Install yq | ||||||||||||
| run: | | ||||||||||||
| sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq | ||||||||||||
| sudo chmod +x /usr/bin/yq | ||||||||||||
|
|
||||||||||||
| - name: Set Kubernetes context | ||||||||||||
| uses: azure/k8s-set-context@v4 | ||||||||||||
| with: | ||||||||||||
| kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} # This uses your Org-level secret | ||||||||||||
|
|
||||||||||||
| # 2. Update the image tag for the *authentication* service | ||||||||||||
| - name: Update image tag in YAML | ||||||||||||
| run: | | ||||||||||||
| 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 | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Image tag format incompatible with new tagging scheme. This workflow uses SHA-only tags ( Update the image reference to match the new format from build.yaml: - name: Update image tag in YAML
run: |
- 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
+ BRANCH="${{ github.event.workflow_run.head_branch }}"
+ yq -i '(select(.kind == "Deployment") | .spec.template.spec.containers[0].image) = "ghcr.io/techtorque-2025/authentication:'"${BRANCH}"'-${{ steps.get_sha.outputs.sha }}"' config-repo/k8s/services/auth-deployment.yamlHowever, given that update-manifest.yaml appears to replace this workflow with a GitOps approach, consider removing this file entirely. 📝 Committable suggestion
Suggested change
|
||||||||||||
|
|
||||||||||||
| # --- NEW DEBUGGING STEP --- | ||||||||||||
| - name: Display file contents before apply | ||||||||||||
| run: | | ||||||||||||
| echo "--- Displaying k8s/services/auth-deployment.yaml ---" | ||||||||||||
| cat config-repo/k8s/services/auth-deployment.yaml | ||||||||||||
| echo "------------------------------------------------------" | ||||||||||||
|
|
||||||||||||
| # 3. Deploy the updated file | ||||||||||||
| - name: Deploy to Kubernetes | ||||||||||||
| run: | | ||||||||||||
| kubectl apply -f config-repo/k8s/services/auth-deployment.yaml | ||||||||||||
| kubectl rollout status deployment/auth-deployment | ||||||||||||
|
Comment on lines
+1
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Clarify the status of this .old file. The If this workflow is no longer needed:
If it's kept for reference or rollback purposes:
# DEPRECATED: This workflow has been replaced by update-manifest.yaml
# Kept for reference only - DO NOT USE
# See: update-manifest.yaml for the current GitOps-based deployment approach🤖 Prompt for AI Agents |
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,88 @@ | ||||||||||||||||||||||||||||
| # GitHub Actions Workflow Template for GitOps with ArgoCD | ||||||||||||||||||||||||||||
| # This workflow should replace the old deploy.yaml in each microservice repo | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| name: Update K8s Manifest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||
| workflow_run: | ||||||||||||||||||||||||||||
| workflows: ["Build and Package Service"] # Or "Build, Test, and Package Frontend" for Frontend_Web | ||||||||||||||||||||||||||||
| types: [completed] | ||||||||||||||||||||||||||||
| branches: ['main', 'dev'] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||
| update-manifest: | ||||||||||||||||||||||||||||
| name: Update Image Tag in k8s-config | ||||||||||||||||||||||||||||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||
| - name: Get branch and SHA info | ||||||||||||||||||||||||||||
| id: info | ||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||
| BRANCH="${{ github.event.workflow_run.head_branch }}" | ||||||||||||||||||||||||||||
| SHORT_SHA="$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" | ||||||||||||||||||||||||||||
| echo "branch=${BRANCH}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| echo "sha=${SHORT_SHA}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||
| echo "📍 Branch: ${BRANCH}, SHA: ${SHORT_SHA}" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - name: Checkout k8s-config repo (matching branch) | ||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||
| repository: 'TechTorque-2025/k8s-config' | ||||||||||||||||||||||||||||
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||||||||||||||||||||||||||||
| ref: ${{ steps.info.outputs.branch }} # Checkout dev or main to match microservice branch | ||||||||||||||||||||||||||||
| path: 'k8s-config' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+35
|
||||||||||||||||||||||||||||
| path: 'k8s-config' | |
| path: 'k8s-config' | |
| continue-on-error: true | |
| - name: Fallback to main branch if needed | |
| if: failure() | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: 'TechTorque-2025/k8s-config' | |
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| ref: 'main' | |
| path: 'k8s-config' |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing security flag for wget command. The wget command uses -qO but doesn't verify the downloaded binary's integrity. Consider adding checksum verification or using the -q with --secure-protocol option. Additionally, downloading from latest can lead to non-reproducible builds. Consider pinning to a specific version:
VERSION="v4.35.1" # or latest stable version
sudo wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_amd64
echo "expected_checksum /usr/bin/yq" | sha256sum -c
sudo chmod +x /usr/bin/yq| sudo wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| YQ_VERSION="v4.35.1" | |
| YQ_BINARY_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" | |
| YQ_CHECKSUM_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/checksums" | |
| sudo wget -qO /usr/bin/yq "${YQ_BINARY_URL}" | |
| wget -qO /tmp/yq_checksums "${YQ_CHECKSUM_URL}" | |
| grep "yq_linux_amd64" /tmp/yq_checksums | sha256sum -c --ignore-missing |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded service-specific values should be parameterized. These SERVICE_NAME and DEPLOYMENT_FILE values are specific to the authentication service and would need to be manually changed for each microservice. Consider using repository variables or deriving these from the repository name to make this workflow reusable across different microservices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Eliminate hardcoded service-specific values.
The SERVICE_NAME (authentication) and DEPLOYMENT_FILE (auth-deployment.yaml) are hardcoded in multiple locations despite comments suggesting they should be parameterized. This makes the "template" non-reusable across different services.
Consider using repository variables or extracting from repository name:
- name: Update image tag in deployment manifest
env:
- SERVICE_NAME: "authentication" # e.g., "timelogging_service", "frontend_web", "authentication"
- DEPLOYMENT_FILE: "auth-deployment.yaml" # e.g., "timelogging-deployment.yaml", "frontend-deployment.yaml"
+ SERVICE_NAME: ${{ vars.SERVICE_NAME }}
+ DEPLOYMENT_FILE: ${{ vars.DEPLOYMENT_FILE }}And update the summary step:
echo "- **Branch**: ${{ steps.info.outputs.branch }}" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: ${{ steps.info.outputs.branch }}-${{ steps.info.outputs.sha }}" >> $GITHUB_STEP_SUMMARY
- echo "- **Manifest Updated**: k8s/services/auth-deployment.yaml" >> $GITHUB_STEP_SUMMARY
+ echo "- **Manifest Updated**: k8s/services/${{ env.DEPLOYMENT_FILE }}" >> $GITHUB_STEP_SUMMARY
echo "- **Next Step**: ArgoCD will sync this change to the cluster" >> $GITHUB_STEP_SUMMARYAlso applies to: 60-60, 87-87
🤖 Prompt for AI Agents
.github/workflows/update-manifest.yaml lines 43-44 (and also adjust occurrences
at lines 60 and 87): the SERVICE_NAME and DEPLOYMENT_FILE are hardcoded; change
them to use workflow inputs or repository/organization variables (e.g., inputs
defined in the workflow or GitHub repository secrets/variables or derive from
github.repository) so the file becomes a reusable template; replace hardcoded
values with references to the chosen inputs/vars, ensure parsing logic derives
SERVICE_NAME from the repo name if needed, and update the summary step to
reference the new variables instead of literal
"authentication"/"auth-deployment.yaml".
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate hardcoded SERVICE_NAME value. This is the same hardcoded value as in the previous step (line 43). This duplication could lead to inconsistencies if one is updated but not the other. Consider defining this once at the job or workflow level using environment variables.
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded deployment file name. This value is hardcoded and specific to the authentication service. It should match the DEPLOYMENT_FILE variable defined earlier but is duplicated here, creating another maintenance point. Consider using a job-level environment variable to define this once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Artifact name changed from
auth-service-jarto genericservice-jar. While this makes the workflow more generic, it could cause issues if multiple services use the same artifact name in parallel workflows. The previous nameauth-service-jarwas more specific and less likely to collide. Consider using a name that includes the repository name or a unique identifier: