ci: rewrite pipeline to use direct git clone instead of GitHub actions
- Removes dependency on actions/checkout, actions/setup-node etc. - Uses direct git clone via internal service URL for reliable checkout - Adds container option with DNS for quality job - Keeps all quality, build, and deploy stages
This commit is contained in:
+32
-41
@@ -7,14 +7,15 @@ on:
|
||||
jobs:
|
||||
quality-and-security:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:20-alpine
|
||||
options: --dns 10.43.0.10
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
git clone http://gitea-http.gitea.svc.cluster.local:3000/${{ gitea.repository }}.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
- name: Install dependencies (API)
|
||||
run: cd api && npm install
|
||||
@@ -30,51 +31,41 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
run: |
|
||||
git clone http://gitea-http.gitea.svc.cluster.local:3000/${{ gitea.repository }}.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver-opts: network=host
|
||||
- name: Build API Docker Image
|
||||
run: docker build -t git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }} ./api
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.88.96.58.76.nip.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
- name: Build Frontend Docker Image
|
||||
run: docker build -t git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }} ./frontend
|
||||
|
||||
- name: Build and push API
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./api
|
||||
push: true
|
||||
tags: git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ github.sha }}
|
||||
- name: Login to Gitea Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.88.96.58.76.nip.io -u ${{ gitea.repository_owner }} --password-stdin
|
||||
|
||||
- name: Build and push Frontend
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./frontend
|
||||
push: true
|
||||
tags: git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ github.sha }}
|
||||
- name: Push API Image
|
||||
run: docker push git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }}
|
||||
|
||||
- name: Push Frontend Image
|
||||
run: docker push git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }}
|
||||
|
||||
deploy:
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout GitOps Repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: khalil/tamagotchi-gitops
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Update ArgoCD k8s.yaml Manifest
|
||||
- name: Clone GitOps Repo
|
||||
run: |
|
||||
sed -i "s|image: tamagotchi-api:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ github.sha }}|g" k8s.yaml
|
||||
sed -i "s|image: tamagotchi-frontend:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ github.sha }}|g" k8s.yaml
|
||||
|
||||
git clone http://gitea-http.gitea.svc.cluster.local:3000/khalil/tamagotchi-gitops.git .
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@gitea.local"
|
||||
|
||||
- name: Update ArgoCD Manifest
|
||||
run: |
|
||||
sed -i "s|image: .*tamagotchi-api:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-api:${{ gitea.sha }}|g" k8s.yaml
|
||||
sed -i "s|image: .*tamagotchi-frontend:.*|image: git.88.96.58.76.nip.io/khalil/tamagotchi-frontend:${{ gitea.sha }}|g" k8s.yaml
|
||||
|
||||
- name: Push Updated Manifest
|
||||
run: |
|
||||
git add k8s.yaml
|
||||
git commit -m "chore: Update image tags to ${{ github.sha }} [skip ci]"
|
||||
git push
|
||||
git diff --cached --quiet && echo "No changes to commit" || (git commit -m "chore: Update image tags to ${{ gitea.sha }} [skip ci]" && git push)
|
||||
|
||||
Reference in New Issue
Block a user