Build for DR #5
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
name: Build for DR | |
on: | |
push: | |
branches: | |
- dev | |
workflow_dispatch: {} | |
concurrency: | |
cancel-in-progress: true | |
group: report-server-build | |
permissions: | |
id-token: write | |
contents: read | |
issues: write | |
env: | |
GITHUB_ORGANIZATION: ${{ github.repository_owner }} | |
GITHUB_REPO_NAME: ${{ github.event.repository.name }} | |
GITHUB_BRANCH_OR_TAG: ${{ github.ref_name }} | |
GITHUB_REF: ${{ github.ref }} | |
BUILD_NAME: ${{github.event_name}} | |
BUILD_NUMBER: ${{github.run_id}} | |
ECR_ADDRESS: 917902836630.dkr.ecr.us-east-1.amazonaws.com | |
DR_ECR_ADDRESS: 973422231492.dkr.ecr.us-west-2.amazonaws.com | |
AWS_REGION : "us-east-1" | |
DR_AWS_REGION : "us-west-2" | |
ECR_REPO: 917902836630.dkr.ecr.us-east-1.amazonaws.com/report-server | |
DR_ECR_REPO: 973422231492.dkr.ecr.us-west-2.amazonaws.com/report-server | |
jobs: | |
build_job: | |
name: Docker Build and Push | |
runs-on: ubuntu-latest | |
outputs: | |
IMAGE_NAME: ${{ steps.sha.outputs.IMAGE_NAME }} | |
IMAGE_SHA: ${{ steps.sha.outputs.SHORT_SHA }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: configure aws DR credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::973422231492:role/cmiml-dr-oidc-github-role | |
role-session-name: gha-oidc-runner | |
aws-region: ${{ env.DR_AWS_REGION }} | |
- name: Login to DR ECR | |
run: | | |
aws ecr get-login-password --region ${{ env.DR_AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.DR_ECR_ADDRESS }} | |
- name: Generate short sha | |
id: sha | |
run: | | |
SHORT_SHA=$(git rev-parse --short HEAD) | |
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
echo "IMAGE_NAME=${ECR_REPO}:${SHORT_SHA}" >> "$GITHUB_OUTPUT" | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
# build-args: | | |
# PIPENV_EXTRA_ARGS=--dev | |
# cache-to: mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=${{ env.ECR_REPO }}:cache | |
# cache-from: type=registry,ref=${{ env.ECR_REPO }}:cache | |
tags: | | |
${{ env.DR_ECR_REPO }}:latest | |
${{ env.DR_ECR_REPO }}:${{ steps.sha.outputs.SHORT_SHA }} | |
platforms: linux/amd64,linux/arm64 | |