-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPHLUDOS-203-5: Deploy built image to ECR
- Loading branch information
Showing
4 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Deploy to environment | ||
description: Copy image to ECR and deploy CDK | ||
inputs: | ||
env: | ||
description: 'Environment for deployment' | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Fetch history for all branches and tags | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Configure utility AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: arn:aws:iam::505953557276:role/ludos-gh-actions-ecr-push-role | ||
aws-region: eu-west-1 | ||
|
||
- name: 05-deploy.sh | ||
working-directory: ./ | ||
shell: bash | ||
run: ./deploy-scripts/05-deploy-${{ inputs.env }}.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,15 @@ jobs: | |
steps: | ||
- uses: actions/[email protected] | ||
- name: Run 04-lint.sh | ||
run: ./deploy-scripts/04-lint.sh | ||
run: ./deploy-scripts/04-lint.sh | ||
|
||
deploy: | ||
name: '05-deploy.sh' | ||
permissions: | ||
packages: read | ||
runs-on: "ubuntu-22.04" | ||
steps: | ||
- name: Deploy | ||
uses: ./.github/actions/deploy | ||
with: | ||
env: 'dev' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit -o nounset -o pipefail | ||
|
||
# shellcheck source=../scripts/common-functions.sh | ||
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../scripts/common-functions.sh" | ||
|
||
# shellcheck source=./deploy-functions.sh | ||
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/deploy-functions.sh" | ||
|
||
function main() { | ||
parse_env_from_script_name 05-deploy | ||
setup | ||
|
||
start_gh_actions_group "Deploying to ${ENV}" | ||
upload_image_to_ecr | ||
} | ||
|
||
function upload_image_to_ecr() { | ||
require_built_image | ||
|
||
docker tag "${github_image_tag}" "${ecr_image_tag}" | ||
docker push "${ecr_image_tag}" | ||
} | ||
|
||
function setup() { | ||
cd "${repo}" | ||
require_command docker | ||
require_docker_compose | ||
configure_aws_credentials | ||
get_ecr_login_credentials | ||
} | ||
|
||
function get_ecr_login_credentials() { | ||
aws --profile oph-ludos-utility \ | ||
ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 505953557276.dkr.ecr.eu-west-1.amazonaws.com | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters