Skip to content

Multibranch feature/task1 #2

Multibranch feature/task1

Multibranch feature/task1 #2

name: Multibranch pipeline
run-name: Multibranch ${{ github.head_ref || github.ref_name }}
on:
push:
branches:
- main
- release/*
- feature/*
- bugfix/*
workflow_dispatch:
inputs:
skipSmokeTests:
description: Should skip smoke tests?
type: boolean
required: false
default: false
jobs:
properties:
uses: ./.github/workflows/datacenterMap.yml
with:
hubEnv: BACKEND_EMEA_TEST
secrets: inherit
buildTestDeploy:
runs-on: ubuntu-latest
needs: properties
env:
AWS_ACCOUNT: ${{ needs.properties.outputs.AWS_ACCOUNT }}
AWS_KEY: ${{ secrets.BACKEND_EMEA_TEST_AWS_KEY }}
AWS_SECRET: ${{ secrets.BACKEND_EMEA_TEST_AWS_SECRET }}
REGION: ${{ needs.properties.outputs.REGION }}
CLUSTER_NAME: ${{ needs.properties.outputs.CLUSTER_NAME }}
SERVICE_NAME: ${{ needs.properties.outputs.SERVICE_NAME }}
SKIP_SMOKE_TESTS: ${{ (github.event.inputs.skipSmokeTests != null && github.event.inputs.skipSmokeTests == 'true') || 'false' }}
SMOKETEST_BACKEND_PASSWORD: ${{ secrets.BACKEND_EMEA_TEST_SMOKETEST_BACKEND_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: JDK 17 setup
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Maven setup
uses: stCarolas/[email protected]
with:
maven-version: 3.8.2
- name: Build
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package org.jacoco:jacoco-maven-plugin:report
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ env.AWS_KEY }}
aws-secret-access-key: ${{ env.AWS_SECRET }}
aws-region: ${{ env.REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: backend
run: |
docker build -t backend .
docker tag backend:latest $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_REF##*/}
docker tag backend:latest $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_REF##*/}
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
# deploy:
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: assembly-fargate/src/main/resources/fargate/BACKEND_EMEA_TEST/task.json
service: ${{ env.SERVICE_NAME }}
cluster: ${{ env.CLUSTER_NAME }}
wait-for-service-stability: true
- name: Run smoke tests
if: ${{ env.SKIP_SMOKE_TESTS == 'false' }}
run: |
mvn -f pom.xml clean test -P st,BACKEND_EMEA_TEST
pipelinePassed:
runs-on: ubuntu-latest
needs: buildTestDeploy
steps:
- name: All passed
run: |
echo "All steps have passed."