Skip to content

Commit

Permalink
We ball
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 authored Aug 11, 2024
1 parent 58604fe commit 70a2e4d
Showing 1 changed file with 37 additions and 56 deletions.
93 changes: 37 additions & 56 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Set outputs
id: vars
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install Dependencies and Compile Assets
- name: Install Docker Compose
run: |
npm install
npm run prod
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Make Cache Directory
run: mkdir bootstrap/cache

- name: Build Docker Image
run: docker-compose build --no-cache
Expand All @@ -45,55 +40,41 @@ jobs:
- name: Push to Docker Hub (Master)
if: contains(github.ref, 'master')
run: |
docker tag vatusa/www vatusa/www:${{ steps.vars.outputs.sha_short }}
docker push vatusa/www:${{ steps.vars.outputs.sha_short }}
docker tag vatusa/www vatusa/www:${{ github.sha }}
docker push vatusa/www:${{ github.sha }}
- name: Push to Docker Hub (Dev)
if: contains(github.ref, 'dev')
run: |
docker tag vatusa/www vatusa/www:dev
docker push vatusa/www:dev
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.21.2'
docker tag vatusa/www vatusa/www:dev-${{ github.sha }}
docker push vatusa/www:dev-${{ github.sha }}
- name: Create kubeconfig
run: |
mkdir ~/.kube
cat << EOF > ~/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${{ secrets.KUBECONFIG_CLUSTER_CERT_AUTH_DATA }}
server: ${{ secrets.KUBECONFIG_CLUSTER_SERVER }}
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}
contexts:
- context:
cluster: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}
user: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}
current-context: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}
kind: Config
preferences: {}
users:
- name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin
user:
token: ${{ secrets.KUBECONFIG_CLUSTER_TOKEN }}
EOF
- name: Deploy to Kubernetes Cluster - Update Deployment
if: contains(github.ref, 'master')
deploy:
name: Deploy to ArgoCD
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
repository: 'VATUSA/gitops'
path: gitops
token: ${{ secrets.G_TOKEN }}
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2
- name: Update manifests
run: |
kubectl set image deployment/www *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web
- name: Deploy to Kubernetes Cluster - Update Cron Job
if: contains(github.ref, 'master')
cd $GITHUB_WORKSPACE/gitops/current
kustomize edit set image vatusa/www=vatusa/www:${{ github.sha }}
- name: Commit and push changes
run: |
kubectl set image cronjob/www-cron *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web
- name: Deploy to Kubernetes Cluster - Update Queue Worker
if: contains(github.ref, 'master')
cd $GITHUB_WORKSPACE/gitops
git config --global user.email "[email protected]"
git config --global user.name "VATUSA6"
git add .
git commit -m "Update WWW image tag to ${{ github.sha }}"
- name: Push to gitops repo
run: |
kubectl set image deployment/www-queue *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web
cd $GITHUB_WORKSPACE/gitops
git push origin main

0 comments on commit 70a2e4d

Please sign in to comment.