diff --git a/.github/workflows/admin-feature.yml b/.github/workflows/admin-ci.yml similarity index 91% rename from .github/workflows/admin-feature.yml rename to .github/workflows/admin-ci.yml index 1cabc086f..2a78dc0ac 100644 --- a/.github/workflows/admin-feature.yml +++ b/.github/workflows/admin-ci.yml @@ -6,12 +6,13 @@ on: - develop paths: - "packages/admin/**" - - ".github/workflows/admin-feature.yml" + - "packages/gap-web-ui/**" + - ".github/workflows/admin-ci.yml" - "package.json" - "yarn.lock" jobs: - build: + test: name: Test app runs-on: ubuntu-latest @@ -46,7 +47,7 @@ jobs: run: | yarn workspace admin lint - - name: Build application + - name: Build gap-web-ui run: | yarn workspace gap-web-ui build diff --git a/.github/workflows/admin-promoteToProd.yml b/.github/workflows/admin-prod-cd.yml similarity index 88% rename from .github/workflows/admin-promoteToProd.yml rename to .github/workflows/admin-prod-cd.yml index 8101f8211..d695fe2f5 100644 --- a/.github/workflows/admin-promoteToProd.yml +++ b/.github/workflows/admin-prod-cd.yml @@ -7,15 +7,12 @@ on: paths: - "packages/admin/**" - "packages/gap-web-ui/**" - - ".github/workflows/admin-promoteToProd.yml" + - ".github/workflows/admin-prod-cd.yml" - "package.json" - "yarn.lock" -env: - AWS_REGION: eu-west-2 - jobs: - promoteToProd: + deploy: environment: AWS runs-on: ubuntu-latest @@ -25,7 +22,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} + aws-region: eu-west-2 - name: Login to AWS ECR id: login-ecr diff --git a/.github/workflows/admin-pushImage.yml b/.github/workflows/admin-sandbox-qa-cd.yml similarity index 71% rename from .github/workflows/admin-pushImage.yml rename to .github/workflows/admin-sandbox-qa-cd.yml index 8c20c3549..b0f1f5dcd 100644 --- a/.github/workflows/admin-pushImage.yml +++ b/.github/workflows/admin-sandbox-qa-cd.yml @@ -8,15 +8,12 @@ on: paths: - "packages/admin/**" - "packages/gap-web-ui/**" - - ".github/workflows/admin-pushImage.yml" + - ".github/workflows/admin-sandbox-qa-cd.yml" - "package.json" - "yarn.lock" -env: - AWS_REGION: eu-west-2 - jobs: - build: + test: name: Test app runs-on: ubuntu-latest @@ -67,8 +64,40 @@ jobs: run: | yarn workspace gap-web-ui coverage - imageBuild: - needs: build + build: + environment: AWS + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + # Fetch all commits since we use the total commit count to determine the build version + fetch-depth: 0 + + - name: Setup AWS credentials + uses: aws-actions/configure-aws-credentials@v1-node16 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-2 + + - name: Login to AWS ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Determine & set BUILD_VERSION + run: | + GIT_COUNT=$(git rev-list $GITHUB_SHA --count) + echo "BUILD_VERSION=b_$GIT_COUNT" >> $GITHUB_ENV + echo BUILD_VERSION is ${{ env.BUILD_VERSION }} + + - name: Build, tag and push Docker image to AWS ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: docker build --build-arg APP_NAME=admin -t $ECR_REGISTRY/gap-apply-admin-web:${{ env.BUILD_VERSION }} . + + deploy: + needs: [build, test] environment: AWS runs-on: ubuntu-latest @@ -84,7 +113,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} + aws-region: eu-west-2 - name: Login to AWS ECR id: login-ecr @@ -99,9 +128,7 @@ jobs: - name: Build, tag and push Docker image to AWS ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - run: | - docker build --build-arg APP_NAME=admin -t $ECR_REGISTRY/gap-apply-admin-web:${{ env.BUILD_VERSION }} . - docker push $ECR_REGISTRY/gap-apply-admin-web:${{ env.BUILD_VERSION }} + run: docker push $ECR_REGISTRY/gap-apply-admin-web:${{ env.BUILD_VERSION }} - name: Create env tag env: diff --git a/.github/workflows/applicant-feature.yml b/.github/workflows/applicant-ci.yml similarity index 90% rename from .github/workflows/applicant-feature.yml rename to .github/workflows/applicant-ci.yml index c7349ec67..a7aaaa44c 100644 --- a/.github/workflows/applicant-feature.yml +++ b/.github/workflows/applicant-ci.yml @@ -6,12 +6,13 @@ on: - develop paths: - "packages/applicant/**" - - ".github/workflows/applicant-feature.yml" + - "packages/gap-web-ui/**" + - ".github/workflows/applicant-ci.yml" - "package.json" - "yarn.lock" jobs: - build: + test: name: Test app runs-on: ubuntu-latest @@ -45,7 +46,7 @@ jobs: run: | yarn workspace applicant lint - - name: Build application + - name: Build gap-web-ui run: | yarn workspace gap-web-ui build diff --git a/.github/workflows/applicant-promoteToProd.yml b/.github/workflows/applicant-prod-cd.yml similarity index 88% rename from .github/workflows/applicant-promoteToProd.yml rename to .github/workflows/applicant-prod-cd.yml index 66154bdf0..8e64ff6a5 100644 --- a/.github/workflows/applicant-promoteToProd.yml +++ b/.github/workflows/applicant-prod-cd.yml @@ -7,15 +7,12 @@ on: paths: - "packages/applicant/**" - "packages/gap-web-ui/**" - - ".github/workflows/applicant-promoteToProd.yml" + - ".github/workflows/applicant-prod-cd.yml" - "package.json" - "yarn.lock" -env: - AWS_REGION: eu-west-2 - jobs: - promoteToProd: + deploy: environment: AWS runs-on: ubuntu-latest @@ -25,7 +22,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} + aws-region: eu-west-2 - name: Login to AWS ECR id: login-ecr diff --git a/.github/workflows/applicant-pushImage.yml b/.github/workflows/applicant-sandbox-qa-cd.yml similarity index 71% rename from .github/workflows/applicant-pushImage.yml rename to .github/workflows/applicant-sandbox-qa-cd.yml index 815435640..a98c51e1f 100644 --- a/.github/workflows/applicant-pushImage.yml +++ b/.github/workflows/applicant-sandbox-qa-cd.yml @@ -8,15 +8,12 @@ on: paths: - "packages/applicant/**" - "packages/gap-web-ui/**" - - ".github/workflows/applicant-pushImage.yml" + - ".github/workflows/applicant-sandbox-qa-cd.yml" - "package.json" - "yarn.lock" -env: - AWS_REGION: eu-west-2 - jobs: - build: + test: name: Test app runs-on: ubuntu-latest @@ -66,7 +63,7 @@ jobs: run: | yarn workspace gap-web-ui coverage - imageBuild: + build: needs: build environment: AWS @@ -83,7 +80,7 @@ jobs: with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} + aws-region: eu-west-2 - name: Login to AWS ECR id: login-ecr @@ -98,9 +95,41 @@ jobs: - name: Build, tag and push Docker image to AWS ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: docker build --build-arg APP_NAME=applicant -t $ECR_REGISTRY/gap-apply-applicant-web:${{ env.BUILD_VERSION }} . + + deploy: + needs: [build, test] + + environment: AWS + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + # Fetch all commits since we use the total commit count to determine the build version + fetch-depth: 0 + + - name: Setup AWS credentials + uses: aws-actions/configure-aws-credentials@v1-node16 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-west-2 + + - name: Login to AWS ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Determine & set BUILD_VERSION run: | - docker build --build-arg APP_NAME=applicant -t $ECR_REGISTRY/gap-apply-applicant-web:${{ env.BUILD_VERSION }} . - docker push $ECR_REGISTRY/gap-apply-applicant-web:${{ env.BUILD_VERSION }} + GIT_COUNT=$(git rev-list $GITHUB_SHA --count) + echo "BUILD_VERSION=b_$GIT_COUNT" >> $GITHUB_ENV + echo BUILD_VERSION is ${{ env.BUILD_VERSION }} + + - name: Build, tag and push Docker image to AWS ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: docker push $ECR_REGISTRY/gap-apply-applicant-web:${{ env.BUILD_VERSION }} - name: Create env tag env: diff --git a/.github/workflows/gap-web-ui-feature.yml b/.github/workflows/gap-web-ui-ci.yml similarity index 93% rename from .github/workflows/gap-web-ui-feature.yml rename to .github/workflows/gap-web-ui-ci.yml index f67c1eed9..4ed3a8260 100644 --- a/.github/workflows/gap-web-ui-feature.yml +++ b/.github/workflows/gap-web-ui-ci.yml @@ -6,12 +6,12 @@ on: - develop paths: - "packages/gap-web-ui/**" - - ".github/workflows/gap-web-ui-feature.yml" + - ".github/workflows/gap-web-ui-ci.yml" - "package.json" - "yarn.lock" jobs: - build: + test: name: Test app runs-on: ubuntu-latest