From f43b371c640510222c6aa2ab45eb1ca1bf760be5 Mon Sep 17 00:00:00 2001 From: Fredrik Monsen Date: Fri, 19 Apr 2024 14:03:33 +0200 Subject: [PATCH] Set conditional rules --- .github/workflows/ci_pipeline.yml | 49 ++++++++----------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci_pipeline.yml b/.github/workflows/ci_pipeline.yml index 88b860e..56dce8e 100644 --- a/.github/workflows/ci_pipeline.yml +++ b/.github/workflows/ci_pipeline.yml @@ -1,14 +1,14 @@ name: CI/CD Pipeline -on: [push] -# push: -# branches: -# - "**" -# tags: -# - "v*.*.*" -# pull_request: -# branches: -# - "main" +on: + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: + branches: + - "main" env: APP_VERSION: ${{ github.ref_name }} @@ -36,23 +36,10 @@ jobs: - name: Build application run: npm run build -# - name: Cache node_modules -# uses: actions/cache@v4 -# with: -# path: ~/.npm -# key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} -# restore-keys: ${{ runner.os }}-node_modules- -# -# - name: Upload build artifact -# uses: actions/upload-artifact@v4 -# with: -# name: next-build -# path: .next - build-and-publish: name: Create and push Docker image needs: lint-and-test - # if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') runs-on: [self-hosted, Linux] steps: - name: Checkout the repository @@ -63,17 +50,6 @@ jobs: with: driver: docker -# - name: Restore node_modules from cache -# uses: actions/cache@v4 -# with: -# path: node_modules -# key: ${{ runner.os }}-node_modules- -# -# - name: Download build artifact -# uses: actions/download-artifact@v4 -# with: -# name: next-build - - name: Import secrets id: import-secrets uses: hashicorp/vault-action@v3 @@ -118,7 +94,7 @@ jobs: name: Deploy stage environment needs: build-and-publish runs-on: [self-hosted, Linux] - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' environment: stage steps: - name: Checkout the repository @@ -152,4 +128,5 @@ jobs: kubectl config use-context tekst kubectl config view kubectl version - kubectl apply -f k8s/stage \ No newline at end of file + kubectl apply -f k8s/stage + kubectl rollout restart deployment hugin-deployment \ No newline at end of file