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