Skip to content

Commit

Permalink
chore(ci): test pushing docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Aug 15, 2024
1 parent f6308ec commit 0b81a18
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
6 changes: 5 additions & 1 deletion .github/actions/containerize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ runs:
with:
username: ${{ inputs['dockerhub-username'] }}
password: ${{ inputs['dockerhub-token'] }}

- name: Login to Amazon ECR
if: inputs.push == true
uses: aws-actions/amazon-ecr-login

- name: Build docker image
uses: docker/build-push-action@v6
Expand All @@ -64,4 +68,4 @@ runs:
SENTRY_AUTH_TOKEN=${{ inputs['sentry-token'] }}
SENTRY_ORG=${{inputs['sentry-org']}}
SENTRY_PROJECT=${{inputs['sentry-project']}}
PORT=${{inputs['app-port']}}
PORT=${{inputs['app-port']}}
4 changes: 2 additions & 2 deletions .github/workflows/account-data-deleter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ jobs:
# Let's try building and conidtionally pushing our docker image to the necessary account.
build-and-push-image:
uses: ./.github/workflows/reuse-build-and-push-image.yml
#needs: [infrastructure]
needs: [infrastructure]
with:
scope: account-data-deleter
app-path: servers/account-data-deleter
app-port: 4015
sentry-project: account-data-deleter
docker-repo-name-short-hand: accountdatadeleter
docker-repo-name-pattern: accountdatadeleter-{0}-app
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/list-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ jobs:
scope: list-api
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

# Let's test the service against some real life and mocked docker services.
build-and-push-image:
uses: ./.github/workflows/reuse-build-and-push-image.yml
with:
scope: list-api
app-path: servers/list-api
app-port: 4005
sentry-project: list-api
docker-repo-name-short-hand: listapi
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

# It's infrastructure time, run the infrastructure update commands
infrastructure:
Expand All @@ -43,4 +31,15 @@ jobs:
scope: list-api-cdk
stack-output-path: infrastructure/list-api/cdktf.out/stacks/list-api
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

build-and-push-image:
uses: ./.github/workflows/reuse-build-and-push-image.yml
with:
scope: list-api
app-path: servers/list-api
app-port: 4005
sentry-project: list-api
docker-repo-name-pattern: listapi-{0}-app
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit
19 changes: 13 additions & 6 deletions .github/workflows/reuse-build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
description: 'Turbo Repo scope to run the build for'
required: true
type: string
docker-repo-name-short-hand:
description: 'Docker name of the repo <account-id>.dkr.ecr.us-east-1.amazonaws.com/<name>'
docker-repo-name-pattern:
description: 'Docker name of the repo <account-id>.dkr.ecr.us-east-1.amazonaws.com/<name>. {0} is replaced with dev or prod'
required: true
type: string
development-aws-registry:
Expand Down Expand Up @@ -49,10 +49,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
# TODO: Change this to the right roles when setup
role-to-assume: arn:aws:iam::410318598490:role/GithubTesting-Daniel
- name: Build Docker Image
uses: ./.github/actions/containerize
with:
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-prod-app
docker-repo-name: ${{inputs['development-aws-registry']}}/${{format(inputs['docker-repo-name-pattern'], 'prod')}}
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
Expand All @@ -79,7 +85,7 @@ jobs:
- name: Build and Push Development Docker Image
uses: ./.github/actions/containerize
with:
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-dev-app
docker-repo-name: ${{inputs['development-aws-registry']}}/${{format(inputs['docker-repo-name-pattern'], 'dev')}}
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
Expand All @@ -88,7 +94,7 @@ jobs:
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}}
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}}
scope: ${{inputs['scope']}}
push: false
push: true


production:
Expand All @@ -107,7 +113,7 @@ jobs:
- name: Build and Push Production Docker Image
uses: ./.github/actions/containerize
with:
docker-repo-name: ${{inputs['development-aws-registry']}}/${{inputs['docker-repo-name-short-hand']}}-prod-app
docker-repo-name: ${{inputs['development-aws-registry']}}/${{format(inputs['docker-repo-name-pattern'], 'prod')}}
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
Expand All @@ -116,3 +122,4 @@ jobs:
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}}
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}}
scope: ${{inputs['scope']}}
push: true
4 changes: 2 additions & 2 deletions .github/workflows/user-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ jobs:
# Let's try building and conidtionally pushing our docker image to the necessary account.
build-and-push-image:
uses: ./.github/workflows/reuse-build-and-push-image.yml
#needs: [infrastructure]
needs: [infrastructure]
with:
scope: user-api
app-path: servers/user-api
app-port: 4006
sentry-project: user-api
docker-repo-name-short-hand: userapi
docker-repo-name-pattern: userapi-{0}-app
# Ensure the re-usable workflow is allowed to access the secrets
secrets: inherit

Expand Down

0 comments on commit 0b81a18

Please sign in to comment.