init #17
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: BACKEND | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- backend/** | |
jobs: | |
build-test-push: | |
name: Build, Test, and Push to ECR | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Verify Working Directory and Files | |
run: | | |
pwd | |
ls -la | |
working-directory: backend | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
path: backend | |
- name: Install Dependencies | |
run: | | |
npm install | |
working-directory: backend | |
- name: Run Tests | |
run: | | |
npm run test:cov | |
working-directory: backend | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Automatic Tagging of Releases | |
id: increment-git-tag | |
run: | | |
bash ./backend/update-version.sh -v patch | |
working-directory: backend | |
- name: Build, Tag, and Push the Image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.BACKEND_ECR_REPOSITORY }} | |
IMAGE_TAG: ${{ steps.increment-git-tag.outputs.git-tag }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./backend | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
working-directory: backend |