-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b74532e
commit 4e4b23e
Showing
1 changed file
with
41 additions
and
64 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 |
---|---|---|
@@ -1,69 +1,46 @@ | ||
name: promote | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
module: | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
required: true | ||
type: choice | ||
options: | ||
- dev | ||
- test | ||
- sbx | ||
- prod | ||
- prod-test | ||
module: | ||
required: true | ||
type: choice | ||
options: | ||
- api | ||
- worker | ||
|
||
release: | ||
types: [released] | ||
push: | ||
# branches: | ||
# - "" | ||
|
||
jobs: | ||
promote: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | ||
|
||
steps: | ||
- name: Assume role in AB2D Management account | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
aws-region: ${{ vars.AWS_REGION }} | ||
role-to-assume: arn:aws:iam::${{ secrets.MGMT_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-mgmt-github-actions | ||
|
||
- name: Retag images in ECR | ||
run: | | ||
ECR_REPO_DOMAIN="${{ secrets.MGMT_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com" | ||
ECR_REPO_URI="$ECR_REPO_DOMAIN/ab2d_${{ inputs.module }}" | ||
# Define target tags based on the environment | ||
if [ "${{ inputs.environment }}" == "sandbox" ]; then | ||
TARGET_TAG="sandbox-latest" | ||
elif [ "${{ inputs.environment }}" == "prod" ]; then | ||
TARGET_TAG="prod-latest" | ||
elif [ "${{ inputs.environment }}" == "prod-test" ]; then | ||
TARGET_TAG="prod-test-latest" | ||
else | ||
echo "Unsupported environment: ${{ inputs.environment }}" | ||
exit 1 | ||
fi | ||
# Get the manifest of the latest image | ||
MANIFEST=$(aws ecr batch-get-image --repository-name "ab2d_${{ inputs.module }}" --image-ids imageTag=ab2d-test-latest --output text --query 'images[].imageManifest') | ||
# Retag the image | ||
aws ecr put-image --repository-name "ab2d_${{ inputs.module }}" --image-tag "$TARGET_TAG" --image-manifest "$MANIFEST" | ||
- name: Verify new tags | ||
run: | | ||
aws ecr describe-images --repository-name "ab2d_${{ inputs.module }}" | ||
uses: ./.github/workflows/promote.yml | ||
secrets: inherit | ||
|
||
promote-sandbox: | ||
needs: promote | ||
permissions: | ||
contents: read | ||
id-token: write | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: sbx | ||
module: ${{ inputs.module }} | ||
secrets: inherit | ||
|
||
promote-prod: | ||
needs: promote | ||
permissions: | ||
contents: read | ||
id-token: write | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: prod | ||
module: ${{ inputs.module }} | ||
secrets: inherit | ||
|
||
promote-prod-test: | ||
needs: promote | ||
permissions: | ||
contents: read | ||
id-token: write | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: prod-test | ||
module: ${{ inputs.module }} | ||
secrets: inherit |