diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..63b3b68f8 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,32 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/DockerFile b/DockerFile new file mode 100644 index 000000000..3b4c04af8 --- /dev/null +++ b/DockerFile @@ -0,0 +1,19 @@ +FROM node:10 + +# Create app directory +WORKDIR /usr/app + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +# If you are building your code for production +# RUN npm ci --only=production + +# Bundle app source +COPY . . + +EXPOSE 8080 +CMD [ "node", "server.js" ] diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 000000000..354d0ae6f --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,39 @@ +# Docker +# Build and push an image to Azure Container Registry +# https://docs.microsoft.com/azure/devops/pipelines/languages/docker + +trigger: +- master + +resources: +- repo: self + +variables: + # Container registry service connection established during pipeline creation + dockerRegistryServiceConnection: '7ca82645-4e44-4cf9-89be-c396b9ec0b3c' + imageRepository: 'kphaniprasadnodejsdocshelloworld' + containerRegistry: 'mynodejs.azurecr.io' + dockerfilePath: '$(Build.SourcesDirectory)/DockerFile' + tag: '$(Build.BuildId)' + + # Agent VM image name + vmImageName: 'ubuntu-latest' + +stages: +- stage: Build + displayName: Build and push stage + jobs: + - job: Build + displayName: Build + pool: + vmImage: $(vmImageName) + steps: + - task: Docker@2 + displayName: Build and push an image to container registry + inputs: + command: buildAndPush + repository: $(imageRepository) + dockerfile: $(dockerfilePath) + containerRegistry: $(dockerRegistryServiceConnection) + tags: | + $(tag) diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..b473a4d5d --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,31 @@ +trigger: +- master +pool: + vmImage: ubuntu-latest + +stages: +- stage: Build + displayName: Build and push stage + jobs: + - job: Build + displayName: Build + pool: + vmImage: $(vmImageName) + steps: + - task: NodeTool@0 + inputs: + versionSpec: '10.x' + displayName: 'Install Node.js' + - script: | + npm install + npm run build + npm run test + displayName: 'npm install, build, and test' + + - task: Docker@2 + displayName: Push an image + inputs: + azureSubscriptionEndpoint: '$(5a0eee50-4814-4a84-babe-068c6bee0201)' + azureContainerRegistry: '$(classicpipeline.azurecr.io)' + imageName: '$(classicpipeline.azurecr.io.image)' + command: push \ No newline at end of file