diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 58c79cde54..0000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Publish Docker image - -on: - push: - branches: ['master'] - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: thetips4you/testjodejsapp - - - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000000..7d5dc62f98 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,54 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present + - run: npm install + + - name: install the gcloud cli + uses: google-github-actions/setup-gcloud@v0 + with: + project_id: ${{ secrets.GOOGLE_PROJECT }} + service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + install_components: 'gke-gcloud-auth-plugin' + export_default_credentials: true + + - name: build and push the docker image + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud auth configure-docker us-central1-docker.pkg.dev + docker build -t us-central1-docker.pkg.dev/goldengate-1/test-project/node:latest . + docker push us-central1-docker.pkg.dev/goldengate-1/test-project/node:latest + - name: deploy to gke + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud container clusters get-credentials test-cluster --region asia-south1-c + sed -i "s/GOOGLE_PROJECT/$GOOGLE_PROJECT/g" deploymentservice.yml + kubectl apply -f deploymentservice.yml diff --git a/deployment.yml b/deployment.yml index 8468bbd661..722f844855 100644 --- a/deployment.yml +++ b/deployment.yml @@ -16,6 +16,6 @@ spec: spec: containers: - name: nodeserver - image: thetips4you/nodeapp:latest + image: us-central1-docker.pkg.dev/goldengate-1/test-project/nodeapp:latest ports: - containerPort: 3000 diff --git a/deploymentservice.yml b/deploymentservice.yml index ab6f0b707d..849efceaa7 100644 --- a/deploymentservice.yml +++ b/deploymentservice.yml @@ -16,7 +16,7 @@ spec: spec: containers: - name: nodeserver - image: thetips4you/nodeapp:latest + image: asia-south1-docker.pkg.dev/goldengate-1/test-project/code:latest ports: - containerPort: 3000 @@ -33,6 +33,6 @@ spec: type: LoadBalancer ports: - protocol: TCP - port: 5000 + port: 8000 targetPort: 3000 nodePort: 31110 diff --git a/index.js b/index.js index 668a9f8ed6..b848ee1186 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,11 @@ var express = require('express'); var app = express(); app.get('/', function (req, res) { - res.send('{ "response": "Hello From Thetips4you" }'); + res.send('{ "response": "Welcome to Innodata" }'); }); app.get('/will', function (req, res) { - res.send('{ "response": "Hello World" }'); + res.send('{ "response": "Welcome" }'); }); app.get('/ready', function (req, res) { res.send('{ "response": " Great!, It works!" }'); diff --git a/service.yml b/service.yml index 1a0ab51485..dae0bb5df9 100644 --- a/service.yml +++ b/service.yml @@ -8,6 +8,6 @@ spec: type: LoadBalancer ports: - protocol: TCP - port: 5000 + port: 8000 targetPort: 3000 nodePort: 31110 diff --git a/test/test.js b/test/test.js index 2794ef1f03..bf4f29c332 100644 --- a/test/test.js +++ b/test/test.js @@ -1,7 +1,7 @@ var request = require('supertest'); var app = require('../index.js'); describe('GET /will', function() { - it('respond with hello world', function(done) { - request(app).get('/will').expect('{ "response": "Hello World" }', done); + it('respond with Welcome', function(done) { + request(app).get('/will').expect('{ "response": "Welcome" }', done); }); -}); \ No newline at end of file +});