From 70a2e4d3b9167cbd57ee8627bd3846b186b8e6f7 Mon Sep 17 00:00:00 2001 From: Raaj Patel <41763998+Raajheer1@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:54:25 -0500 Subject: [PATCH] We ball --- .github/workflows/ci-master.yml | 93 +++++++++++++-------------------- 1 file changed, 37 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index fc44fe80..8807da3a 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -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 @@ -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 "vatusa6@vatusa.net" + 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 +