Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/workflows/node-api-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
paths:
- services/node-api/**
- .github/workflows/node-api-ci.yaml
pull_request:
paths:
- services/node-api/**
- .github/workflows/node-api-ci.yaml

permissions:
contents: read
Expand Down Expand Up @@ -63,7 +59,6 @@ jobs:
context: services/node-api
push: true
platforms: linux/amd64,linux/arm64

tags: |
${{ env.IMAGE_NAME }}:main
${{ env.IMAGE_NAME }}:${{ github.sha }}
Expand Down
60 changes: 59 additions & 1 deletion .github/workflows/node-api-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ on:
- .github/workflows/node-api-preview.yaml

permissions:
contents: read
contents: write
packages: write
pull-requests: read

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/node-api
Expand Down Expand Up @@ -67,3 +68,60 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.image.outputs.image }}

- name: Checkout main for GitOps update
uses: actions/checkout@v4
with:
ref: main

- name: Generate preview application
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
PREVIEW_NAME="node-api-pr-${PR_NUMBER}"
PREVIEW_NAMESPACE="preview-node-api-pr-${PR_NUMBER}"
IMAGE_TAG="${{ steps.image.outputs.tag }}"

mkdir -p previews/node-api

{
echo "apiVersion: argoproj.io/v1alpha1"
echo "kind: Application"
echo "metadata:"
echo " name: ${PREVIEW_NAME}"
echo " namespace: argo-cd"
echo "spec:"
echo " project: default"
echo " source:"
echo " repoURL: https://github.com/devshinthant/internal-developer-platform.git"
echo " targetRevision: main"
echo " path: charts/node-api"
echo " helm:"
echo " values: |"
echo " image:"
echo " tag: ${IMAGE_TAG}"
echo " replicaCount: 1"
echo " destination:"
echo " server: https://kubernetes.default.svc"
echo " namespace: ${PREVIEW_NAMESPACE}"
echo " syncPolicy:"
echo " automated:"
echo " prune: true"
echo " selfHeal: true"
echo " syncOptions:"
echo " - CreateNamespace=true"
} > "previews/node-api/pr-${PR_NUMBER}.yaml"

- name: Commit preview application
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git add "previews/node-api/pr-${{ github.event.pull_request.number }}.yaml"

if git diff --cached --quiet; then
echo "No preview changes to commit"
exit 0
fi

git commit -m "Update node-api preview for PR #${{ github.event.pull_request.number }}"
git push origin HEAD:main
3 changes: 0 additions & 3 deletions charts/node-api/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ spec:
port: {{ .Values.service.targetPort }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
imagePullSecrets:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}

Loading