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 e13c914
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 47 deletions.
24 changes: 14 additions & 10 deletions .github/actions/containerize/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,23 @@ runs:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ inputs['dockerhub-username'] }}
password: ${{ inputs['dockerhub-token'] }}
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
with:
push: ${{inputs['push']}}
tags: ${{inputs['docker-repo-name']}}:${{ github.sha }}
push: ${{inputs.push}}
tags: ${{inputs.docker-repo-name}}:${{ github.sha }}
build-args: |
GIT_SHA=${{ github.sha }}
SCOPE=${{inputs['scope']}}
APP_PATH=${{inputs['app-path']}}
SENTRY_AUTH_TOKEN=${{ inputs['sentry-token'] }}
SENTRY_ORG=${{inputs['sentry-org']}}
SENTRY_PROJECT=${{inputs['sentry-project']}}
PORT=${{inputs['app-port']}}
SCOPE=${{inputs.scope}}
APP_PATH=${{inputs.app-path}}
SENTRY_AUTH_TOKEN=${{ inputs.sentry-token }}
SENTRY_ORG=${{inputs.sentry-org']}}
SENTRY_PROJECT=${{inputs.sentry-project}}
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
49 changes: 28 additions & 21 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,18 +49,24 @@ 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
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
sentry-org: ${{inputs['sentry-org']}}
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}}
sentry-org: ${{inputs.sentry-org}}
sentry-token: ${{secrets.SENTRY_BEARER}}
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}}
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}}
scope: ${{inputs['scope']}}
scope: ${{inputs.scope}}


development:
Expand All @@ -79,16 +85,16 @@ 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
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
sentry-org: ${{inputs['sentry-org']}}
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}}
sentry-org: ${{inputs.sentry-org}}
sentry-token: ${{secrets.SENTRY_BEARER}}
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}}
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}}
scope: ${{inputs['scope']}}
push: false
scope: ${{inputs.scope}}
push: true


production:
Expand All @@ -107,12 +113,13 @@ 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
app-path: ${{inputs['app-path']}}
app-port: ${{inputs['app-port']}}
sentry-project: ${{inputs['sentry-project']}}
sentry-org: ${{inputs['sentry-org']}}
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}}
sentry-org: ${{inputs.sentry-org}}
sentry-token: ${{secrets.SENTRY_BEARER}}
dockerhub-username: ${{secrets.DOCKERHUB_USERNAME}}
dockerhub-token: ${{secrets.DOCKERHUB_TOKEN}}
scope: ${{inputs['scope']}}
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 e13c914

Please sign in to comment.