Disable deployment to Azure in CI/CD pipeline #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI/CD with Docker | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
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' | |
- name: Install dependencies | |
run: npm install | |
- name: Install AWS SDK (if required separately) | |
run: npm install aws-sdk | |
- name: Run tests | |
run: npm test | |
timeout-minutes: 15 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
PORT: ${{ secrets.PORT }} | |
build-and-push-docker: | |
needs: build-and-test | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and Push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: alfonsoridao/w37l-db-adapter:latest | |
# This is where the Docker build and push steps end. | |
#we will avoid the deployment to Azure for now, using AWS becuase we can handle the domains with Route 53 and the SSL certificates with ACM. | |
# deploy-to-azure: | |
# needs: build-and-push-docker | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Log in to Azure | |
# uses: azure/login@v1 | |
# with: | |
# creds: ${{ secrets.AZURE_CREDENTIALS }} | |
# | |
# - name: Deploy to Azure Container Instances | |
# uses: 'azure/aci-deploy@v1' | |
# with: | |
# resource-group: ${{ secrets.AZURE_RESOURCE_GROUP }} | |
# dns-name-label: w37l-db-adapter-${{ github.run_number }} | |
# image: alfonsoridao/w37l-db-adapter:latest | |
# name: w37l-db-adapter | |
# location: ${{ secrets.AZURE_LOCATION }} | |
# # Set any necessary environment variables for your container: | |
# environment-variables: PORT=${{ secrets.PORT }} AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_S3_BUCKET=${{ secrets.AWS_S3_BUCKET }} AWS_REGION=${{ secrets.AWS_REGION }} | |
# |