Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting out CD jobs more efficiently #106

Merged
merged 5 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +63,7 @@ jobs:
run: |
yarn workspace gap-web-ui coverage

imageBuild:
build:
needs: build

environment: AWS
Expand All @@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading